[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unfreezing the display during auto-repeated scrolling. Simpler appro

From: Alan Mackenzie
Subject: Re: Unfreezing the display during auto-repeated scrolling. Simpler approach.
Date: Fri, 21 Nov 2014 15:44:20 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hello, Stefan and Eli.

This matter was hanging in the air when Emacs was converted to git.

Just a short summary of this change: introduce a new user option, off by
default, which suppresses fontification (by binding
fontification-functions to nil) when the user scrolls by whole screens.

This change is ready to be applied to the Emacs master branch.  Is it OK
to apply it now?

For reference here is the change:

New feature optionally to accelerate auto-repeated scrolling.

src/xdisp.c: Remove "static" from declaration of

src/window.c (window_scroll): bind fontification-functions to nil when
scrolling by whole screens and use-default-face-for-fast-scrolling is
(syms_of_window): New DEFVAR_BOOL use-default-face-for-fast-scrolling.

src/lisp.h (bool): Declare Qfontification_functions extern.

lisp/cus-start.el (all): Add use-default-face-for-fast-scrolling.

doc/emacs/display.texi (Scrolling): use-default-face-for-fast-scrolling.
Describe new variable.

etc/NEWS: Add entry for use-default-face-for-fast-scrolling.

diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog
index aa9804f..409fb54 100644
--- a/doc/emacs/ChangeLog
+++ b/doc/emacs/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-21  Alan Mackenzie  <address@hidden>
+       * display.texi (Scrolling): use-default-face-for-fast-scrolling.
+       Describe new variable.
 2014-11-21  Eli Zaretskii  <address@hidden>
        * maintaining.texi (Version Control Systems): Move "@end itemize"
diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index a5555d5..f655ed3 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 address@hidden @code{scroll-command} property.
 @xref{Property Lists,,, elisp, The Emacs Lisp Reference Manual}.
address@hidden use-default-face-for-fast-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
address@hidden to a address@hidden 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 d57190f..19a542a 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,7 @@
+2014-11-21  Alan Mackenzie  <address@hidden>
+       * NEWS: Add entry for use-default-face-for-fast-scrolling.
 2014-11-19  Leo Liu  <address@hidden>
        * NEWS: Mention new macro define-advice.
diff --git a/etc/NEWS b/etc/NEWS
index 769d2c6..2d27639 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -113,6 +113,12 @@ this has no effect.
 *** A new text property `inhibit-read-only' can be used in read-only
 buffers to allow certain parts of the text to be writable.
+** New variable `use-default-face-for-fast-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/cus-start.el b/lisp/cus-start.el
index 3b8885a..ae29c29 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 
                              :value display-buffer)
                       (other :tag "Always (t)" :value t))
+            (use-default-face-for-fast-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 b169479..f660642 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,18 @@
+2014-11-21  Alan Mackenzie  <address@hidden>
+       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
+       use-default-face-for-fast-scrolling is non-nil.
+       (syms_of_window): New DEFVAR_BOOL
+       use-default-face-for-fast-scrolling.
+       * lisp.h (bool): Declare Qfontification_functions extern.
 2014-11-17  Paul Eggert  <address@hidden>
        Improve time stamp handling, and be more consistent about it.
diff --git a/src/lisp.h b/src/lisp.h
index bdff019..7dfd1fa 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -829,6 +829,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 7c2b3ca..2585d32 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 && Vuse_default_face_for_fast_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)
     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 
 pixelwise even if this option is nil.  */);
   window_resize_pixelwise = 0;
+  DEFVAR_BOOL ("use-default-face-for-fast-scrolling",
+               Vuse_default_face_for_fast_scrolling,
+               doc: /* When non-nil, accelerate repeated 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.  */);
+  Vuse_default_face_for_fast_scrolling = 0;
   defsubr (&Sselected_window);
   defsubr (&Sminibuffer_window);
   defsubr (&Swindow_minibuffer_p);
diff --git a/src/xdisp.c b/src/xdisp.c
index 1b015e7..5751693 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;

Alan Mackenzie (Nuremberg, Germany).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]