emacs-diffs
[Top][All Lists]
Advanced

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

master fdf148c 1/2: Fix unwarranted point movement after C-g


From: Eli Zaretskii
Subject: master fdf148c 1/2: Fix unwarranted point movement after C-g
Date: Sun, 15 Aug 2021 07:19:05 -0400 (EDT)

branch: master
commit fdf148cab4c0b74028b34dd4d3a2cd9e4efa8c19
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Fix unwarranted point movement after C-g
    
    When the same buffer is displayed in more than one window,
    redisplay temporarily moves point to the window-point when it
    works on non-selected windows.  If we allow C-g to quit out of
    redisplay_window in this situation, point will appear to have
    moved to the window-point of that non-selected window, which is
    unwarranted.  These changes prevent quitting in strategic places,
    so that we never quit out of redisplay_window.
    * src/xdisp.c (run_window_scroll_functions):
    Prevent quitting while running window-scroll-functions, so that we
    don't quit out of redisplay_window with temporarily moved point.
    (redisplay_window): While redisplaying the mode line, prevent
    quitting, to avoid exiting while point is temporarily moved.
    (decode_mode_spec): Use safe_call1 instead of call1, to trap any
    errors instead of letting them throw out of redisplay.  (Bug#44448)
---
 src/xdisp.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index e62f7e3..ac80827 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -17275,8 +17275,11 @@ run_window_scroll_functions (Lisp_Object window, 
struct text_pos startp)
 
   if (!NILP (Vwindow_scroll_functions))
     {
+      ptrdiff_t count = SPECPDL_INDEX ();
+      specbind (Qinhibit_quit, Qt);
       run_hook_with_args_2 (Qwindow_scroll_functions, window,
                            make_fixnum (CHARPOS (startp)));
+      unbind_to (count, Qnil);
       SET_TEXT_POS_FROM_MARKER (startp, w->start);
       /* In case the hook functions switch buffers.  */
       set_buffer_internal (XBUFFER (w->contents));
@@ -19269,7 +19272,7 @@ redisplay_window (Lisp_Object window, bool 
just_this_one_p)
   w->start_at_line_beg = (CHARPOS (startp) == BEGV
                          || FETCH_BYTE (BYTEPOS (startp) - 1) == '\n');
 
-  /* Display the mode line, if we must.  */
+  /* Display the mode line, header line, and tab-line, if we must.  */
   if ((update_mode_line
        /* If window not full width, must redo its mode line
          if (a) the window to its side is being redone and
@@ -19288,8 +19291,11 @@ redisplay_window (Lisp_Object window, bool 
just_this_one_p)
          || window_wants_header_line (w)
          || window_wants_tab_line (w)))
     {
+      ptrdiff_t count1 = SPECPDL_INDEX ();
 
+      specbind (Qinhibit_quit, Qt);
       display_mode_lines (w);
+      unbind_to (count1, Qnil);
 
       /* If mode line height has changed, arrange for a thorough
         immediate redisplay using the correct mode line height.  */
@@ -19337,7 +19343,7 @@ redisplay_window (Lisp_Object window, bool 
just_this_one_p)
  finish_menu_bars:
 
   /* When we reach a frame's selected window, redo the frame's menu
-     bar and the frame's title.  */
+     bar, tool bar, tab-bar, and the frame's title.  */
   if (update_mode_line
       && EQ (FRAME_SELECTED_WINDOW (f), window))
     {
@@ -25428,8 +25434,8 @@ redisplay_mode_lines (Lisp_Object window, bool force)
 }
 
 
-/* Display the mode and/or header line of window W.  Value is the
-   sum number of mode lines and header lines displayed.  */
+/* Display the mode and/or header line of window W.  Value is the sum
+   number of mode lines, header lines, and tab lines actually displayed.  */
 
 static int
 display_mode_lines (struct window *w)
@@ -27009,7 +27015,7 @@ decode_mode_spec (struct window *w, register int c, int 
field_width,
        Lisp_Object val = Qnil;
 
        if (STRINGP (curdir))
-         val = call1 (intern ("file-remote-p"), curdir);
+         val = safe_call1 (intern ("file-remote-p"), curdir);
 
        val = unbind_to (count, val);
 



reply via email to

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