From 3713931778c9bc8674c391dbb9149ac6288922f2 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Sun, 14 Dec 2014 18:26:44 +0000 Subject: [PATCH] New feature optionally to accelerate auto-repeated scrolling. src/xdisp.c: Remove "static" from declaration of Qfontification_functions. src/window.c (window_scroll): bind fontification-functions to nil when scrolling by whole screens and fast-but-imprecise-scrolling is non-nil. (syms_of_window): New DEFVAR_BOOL fast-but-imprecise-scrolling. src/lisp.h (bool): Declare Qfontification_functions extern. lisp/cus-start.el (all): Add fast-but-imprecise-scrolling. doc/emacs/display.texi (Scrolling): fast-but-imprecise-scrolling. Describe new variable. etc/NEWS: Add entry for fast-but-imprecise-scrolling. --- doc/emacs/ChangeLog | 5 +++++ doc/emacs/display.texi | 13 +++++++++++++ etc/ChangeLog | 4 ++++ etc/NEWS | 6 ++++++ lisp/ChangeLog | 4 ++++ lisp/cus-start.el | 1 + src/ChangeLog | 15 +++++++++++++++ src/lisp.h | 1 + src/window.c | 18 ++++++++++++++++++ src/xdisp.c | 2 +- 10 files changed, 68 insertions(+), 1 deletion(-) diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog index cd46d9fc474..d2f7a345566 100644 --- a/doc/emacs/ChangeLog +++ b/doc/emacs/ChangeLog @@ -1,3 +1,8 @@ +2014-12-14 Alan Mackenzie + + * display.texi (Scrolling): fast-but-imprecise-scrolling. + Describe new variable. + 2014-12-14 Cameron Desautels * custom.texi (Saving Customizations): Mention diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi index a5555d58054..12a8e1b3eee 100644 --- a/doc/emacs/display.texi +++ b/doc/emacs/display.texi @@ -127,6 +127,19 @@ the mouse wheel (@pxref{Mouse Commands}); in general, it affects any command that has a non-@code{nil} @code{scroll-command} property. @xref{Property Lists,,, elisp, The Emacs Lisp Reference Manual}. +@vindex fast-but-imprecise-scrolling + Sometimes, particularly when you hold down keys such as @kbd{C-v} +and @kbd{M-v}, activating keyboard auto-repeat, Emacs fails to keep up +with the rapid rate of scrolling requested; the display doesn't update +and Emacs can become unresponsive to input for quite a long time. You +can counter this sluggishness by setting the variable +@code{fast-but-imprecise-scrolling} to a non-@code{nil} value. This +instructs the scrolling commands not to fontify (@pxref{Font Lock}) +any unfontified text they scroll over, instead to assume it has the +default face. This can cause Emacs to scroll to somewhat wrong buffer +positions when the faces in use are not all the same size, even with +single (i.e. without auto-repeat) scrolling operations. + @vindex scroll-up @vindex scroll-down @findex scroll-up-line diff --git a/etc/ChangeLog b/etc/ChangeLog index f344e2437b0..0a06cbd5c70 100644 --- a/etc/ChangeLog +++ b/etc/ChangeLog @@ -1,3 +1,7 @@ +2014-12-14 Alan Mackenzie + + * NEWS: Add entry for fast-but-imprecise-scrolling. + 2014-12-14 Cameron Desautels * NEWS: Mention `custom-prompt-customize-unsaved-options'. diff --git a/etc/NEWS b/etc/NEWS index 37cb4b42e52..6b1a4e3627d 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -153,6 +153,12 @@ name (as returned from, for instance, `file-name-all-completions' is a directory file name. It returns non-nil if the last character in the name is a forward slash. ++++ +** New variable `fast-but-imprecise-scrolling' inhibits +fontification during full screen scrolling operations, giving less +hesitant operation during auto-repeat of C-v, M-v at the cost of +possible inaccuracies in the end position. + * Editing Changes in Emacs 25.1 diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 288589d9e04..8a0d5181bae 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2014-12-14 Alan Mackenzie + + * lisp/cus-start.el (all): Add fast-but-imprecise-scrolling. + 2014-12-14 Artur Malabarba * let-alist.el: Add lexical binding. diff --git a/lisp/cus-start.el b/lisp/cus-start.el index 3b8885a8717..4049974841e 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el @@ -460,6 +460,7 @@ since it could result in memory overflow and make Emacs crash." :value display-buffer) (other :tag "Always (t)" :value t)) "24.3") + (fast-but-imprecise-scrolling scrolling boolean "25.1") (window-resize-pixelwise windows boolean "24.4") ;; xdisp.c ;; The whitespace group is for whitespace.el. diff --git a/src/ChangeLog b/src/ChangeLog index fd56186105b..46bf2801849 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2014-12-14 Alan Mackenzie + + New feature optionally to accelerate auto-repeated scrolling. + + * xdisp.c: Remove "static" from declaration of + Qfontification_functions. + + * window.c (window_scroll): bind fontification-functions to nil + when scrolling by whole screens and + fast-but-imprecise-scrolling is non-nil. + (syms_of_window): New DEFVAR_BOOL + fast-but-imprecise-scrolling. + + * lisp.h (bool): Declare Qfontification_functions extern. + 2014-12-14 Eli Zaretskii Load system's default trusted Certificate Authorities if available. diff --git a/src/lisp.h b/src/lisp.h index a56c4a73bf8..37172c6b049 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -830,6 +830,7 @@ extern Lisp_Object Qwindowp; /* Defined in xdisp.c. */ extern Lisp_Object Qimage; +extern Lisp_Object Qfontification_functions; /* Extract a value or address from a Lisp_Object. */ diff --git a/src/window.c b/src/window.c index 7c2b3ca29d2..0b766649b17 100644 --- a/src/window.c +++ b/src/window.c @@ -4869,11 +4869,16 @@ window_internal_height (struct window *w) static void window_scroll (Lisp_Object window, EMACS_INT n, bool whole, int noerror) { + ptrdiff_t count = SPECPDL_INDEX (); + immediate_quit = 1; n = clip_to_bounds (INT_MIN, n, INT_MAX); wset_redisplay (XWINDOW (window)); + if (whole && Vfast_but_imprecise_scrolling) + specbind (Qfontification_functions, Qnil); + /* If we must, use the pixel-based version which is much slower than the line-based one but can handle varying line heights. */ if (FRAME_WINDOW_P (XFRAME (XWINDOW (window)->frame))) @@ -4881,6 +4886,8 @@ window_scroll (Lisp_Object window, EMACS_INT n, bool whole, int noerror) else window_scroll_line_based (window, n, whole, noerror); + unbind_to (count, Qnil); + /* Bug#15957. */ XWINDOW (window)->window_end_valid = 0; immediate_quit = 0; @@ -7478,6 +7485,17 @@ frame's character size, at least one window may get resized pixelwise even if this option is nil. */); window_resize_pixelwise = 0; + DEFVAR_BOOL ("fast-but-imprecise-scrolling", + Vfast_but_imprecise_scrolling, + doc: /* When non-nil, accelerate scrolling operations. +This comes into play when scrolling rapidly over previously +unfontified buffer regions. Only those portions of the buffer which +are actually going to be displayed get fontified. + +Note that this optimization can cause the portion of the buffer +displayed after a scrolling operation to be somewhat inaccurate. */); + Vfast_but_imprecise_scrolling = 0; + defsubr (&Sselected_window); defsubr (&Sminibuffer_window); defsubr (&Swindow_minibuffer_p); diff --git a/src/xdisp.c b/src/xdisp.c index f022790023b..48a2979dcde 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -347,7 +347,7 @@ Lisp_Object Qtext; /* Holds the list (error). */ static Lisp_Object list_of_error; -static Lisp_Object Qfontification_functions; +Lisp_Object Qfontification_functions; static Lisp_Object Qwrap_prefix; static Lisp_Object Qline_prefix; -- 2.39.2