emacs-devel
[Top][All Lists]
Advanced

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

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


From: Alan Mackenzie
Subject: Re: Unfreezing the display during auto-repeated scrolling. Simpler approach.
Date: Mon, 27 Oct 2014 14:28:01 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hello, Stefan.

On Sun, Oct 26, 2014 at 09:03:40PM -0400, Stefan Monnier wrote:
> > At this stage, _nothing_ can stop handle_fontified_prop running
> > fontification-functions causing the fontification of >=
> > jit-lock-chunk-size (500) bytes.  Well, my patch stopped this, but
> > nothing else currently in the system can.

> Running fontification-functions does not necessarily imply running
> font-lock!

Neither it does!  :-)  New idea below.

> Please take a look at what jit-lock-defer does.

It sets a non-nil fontified text-property without doing any
fontification (yet).  I think you're suggesting "binding"
jit-lock-defer over the scroll operation, thus inhibiting fontification. 

I've had a simpler idea: bind fontification-functions to nil over the
scroll operation.  This avoids many of the pitfalls of my last patch, and
can be perfectly specific to scrolling by whole screens and nothing else,
and is much simpler and less intrusive.  It works well.

Here's a patch, which does precisely that.  Comments welcome, as always:



=== modified file 'src/lisp.h'
--- src/lisp.h  2014-10-15 13:37:10 +0000
+++ src/lisp.h  2014-10-27 13:19:02 +0000
@@ -829,6 +829,7 @@
 
 /* Defined in xdisp.c.  */
 extern Lisp_Object Qimage;
+extern Lisp_Object Qfontification_functions;
 
 
 /* Extract a value or address from a Lisp_Object.  */

=== modified file 'src/window.c'
--- src/window.c        2014-10-04 08:20:24 +0000
+++ src/window.c        2014-10-27 13:29:51 +0000
@@ -4867,11 +4867,16 @@
 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 && !NILP (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)))
@@ -4879,6 +4884,8 @@
   else
     window_scroll_line_based (window, n, whole, noerror);
 
+  unbind_to (count, Qnil);
+
   /* Bug#15957.  */
   XWINDOW (window)->window_end_valid = 0;
   immediate_quit = 0;
@@ -7468,6 +7475,17 @@
 pixelwise even if this option is nil.  */);
   window_resize_pixelwise = 0;
 
+  DEFVAR_LISP ("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 to
+be slightly different.  */);
+  Vuse_default_face_for_fast_scrolling = Qnil;
+
   defsubr (&Sselected_window);
   defsubr (&Sminibuffer_window);
   defsubr (&Swindow_minibuffer_p);

=== modified file 'src/xdisp.c'
--- src/xdisp.c 2014-10-24 09:58:43 +0000
+++ src/xdisp.c 2014-10-27 13:21:01 +0000
@@ -347,7 +347,7 @@
 /* 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;



>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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