[Top][All Lists]

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

master b2f8c9f 1/2: * src/xdisp.c (syms_of_xdisp): New var redisplay-ski

From: Stefan Monnier
Subject: master b2f8c9f 1/2: * src/xdisp.c (syms_of_xdisp): New var redisplay-skip-fontification-on-input
Date: Mon, 4 Jan 2021 01:00:49 -0500 (EST)

branch: master
commit b2f8c9f96fbda53387b9f910d3b97aefefab6cab
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * src/xdisp.c (syms_of_xdisp): New var redisplay-skip-fontification-on-input
    (handle_fontified_prop): Use it.
    * src/keyboard.h (input_was_pending): Declare.
    * src/keyboard.c (input_was_pending): Make non-static.
 etc/NEWS       |  6 ++++++
 src/keyboard.c |  2 +-
 src/keyboard.h |  2 +-
 src/xdisp.c    | 14 ++++++++++++++
 4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 8003175..d8f25ab 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -212,6 +212,12 @@ This makes debugging Emacs Lisp scripts run in batch mode 
easier.  To
 get back the old behavior, set the new variable
 'backtrace-on-error-noninteractive' to a nil value.
+** 'redisplay-skip-fontification-on-input' helps Emacs keep up with fast input.
+This is another attempt to solve the problem of handling high key repeat rate
+and other "slow scrolling" situations.  It is hoped it behaves better
+than 'fast-but-imprecise-scrolling' and 'jit-lock-defer-time'.
+It is not enabled by default.
 * Editing Changes in Emacs 28.1
diff --git a/src/keyboard.c b/src/keyboard.c
index d2f0cb4..cf15cd7 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -285,7 +285,7 @@ bool input_pending;
    with the input rate, but if it can keep up just enough that there's no
    input_pending when we begin the command, then redisplay is not skipped
    which results in better feedback to the user.  */
-static bool input_was_pending;
+bool input_was_pending;
 /* Circular buffer for pre-read keyboard input.  */
diff --git a/src/keyboard.h b/src/keyboard.h
index 91c6f46..8bdffaa 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -432,7 +432,7 @@ extern int parse_solitary_modifier (Lisp_Object symbol);
 extern Lisp_Object real_this_command;
 extern int quit_char;
+extern bool input_was_pending;
 extern unsigned int timers_run;
 extern bool menu_separator_name_p (const char *);
diff --git a/src/xdisp.c b/src/xdisp.c
index 749893b..43447e2 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -4262,6 +4262,7 @@ handle_fontified_prop (struct it *it)
   if (!STRINGP (it->string)
       && it->s == NULL
       && !NILP (Vfontification_functions)
+      && !(input_was_pending && redisplay_skip_fontification_on_input)
       && !NILP (Vrun_hooks)
       && (pos = make_fixnum (IT_CHARPOS (*it)),
          prop = Fget_char_property (pos, Qfontified, Qnil),
@@ -35598,6 +35599,19 @@ best except in special circumstances such as running 
redisplay tests
 in batch mode.   */);
   redisplay_skip_initial_frame = true;
+  DEFVAR_BOOL ("redisplay-skip-fontification-on-input",
+               redisplay_skip_fontification_on_input,
+    doc: /* Skip `fontification_functions` when there is input pending.
+If non-nil and there was input pending at the beginning of the command,
+the `fontification_functions` hook is not run.  This usually does not
+affect the display because redisplay is completely skipped anyway if input
+was pending, but it can make scrolling smoother by avoiding
+unnecessary fontification.
+It is similar to `fast-but-imprecise-scrolling' with similar tradeoffs,
+but with the advantage that it should only affect the behavior when Emacs
+has trouble keeping up with the incoming input rate.  */);
+  redisplay_skip_fontification_on_input = false;
   DEFVAR_BOOL ("redisplay-adhoc-scroll-in-resize-mini-windows",
     doc: /* If nil always use normal scrolling in minibuffer windows.

reply via email to

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