diff options
| author | Eli Zaretskii | 2021-08-15 14:11:23 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2021-08-15 14:11:23 +0300 |
| commit | fdf148cab4c0b74028b34dd4d3a2cd9e4efa8c19 (patch) | |
| tree | 43b3415cedb5cde3495d74456e61b5e4c9eaf8d1 /src/xdisp.c | |
| parent | e2eb58c4874bc8dedb7f3da9f9e0626ccfe74cdf (diff) | |
| download | emacs-fdf148cab4c0b74028b34dd4d3a2cd9e4efa8c19.tar.gz emacs-fdf148cab4c0b74028b34dd4d3a2cd9e4efa8c19.zip | |
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)
Diffstat (limited to 'src/xdisp.c')
| -rw-r--r-- | src/xdisp.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index e62f7e3df6e..ac80827bc3d 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -17275,8 +17275,11 @@ run_window_scroll_functions (Lisp_Object window, struct text_pos startp) | |||
| 17275 | 17275 | ||
| 17276 | if (!NILP (Vwindow_scroll_functions)) | 17276 | if (!NILP (Vwindow_scroll_functions)) |
| 17277 | { | 17277 | { |
| 17278 | ptrdiff_t count = SPECPDL_INDEX (); | ||
| 17279 | specbind (Qinhibit_quit, Qt); | ||
| 17278 | run_hook_with_args_2 (Qwindow_scroll_functions, window, | 17280 | run_hook_with_args_2 (Qwindow_scroll_functions, window, |
| 17279 | make_fixnum (CHARPOS (startp))); | 17281 | make_fixnum (CHARPOS (startp))); |
| 17282 | unbind_to (count, Qnil); | ||
| 17280 | SET_TEXT_POS_FROM_MARKER (startp, w->start); | 17283 | SET_TEXT_POS_FROM_MARKER (startp, w->start); |
| 17281 | /* In case the hook functions switch buffers. */ | 17284 | /* In case the hook functions switch buffers. */ |
| 17282 | set_buffer_internal (XBUFFER (w->contents)); | 17285 | set_buffer_internal (XBUFFER (w->contents)); |
| @@ -19269,7 +19272,7 @@ redisplay_window (Lisp_Object window, bool just_this_one_p) | |||
| 19269 | w->start_at_line_beg = (CHARPOS (startp) == BEGV | 19272 | w->start_at_line_beg = (CHARPOS (startp) == BEGV |
| 19270 | || FETCH_BYTE (BYTEPOS (startp) - 1) == '\n'); | 19273 | || FETCH_BYTE (BYTEPOS (startp) - 1) == '\n'); |
| 19271 | 19274 | ||
| 19272 | /* Display the mode line, if we must. */ | 19275 | /* Display the mode line, header line, and tab-line, if we must. */ |
| 19273 | if ((update_mode_line | 19276 | if ((update_mode_line |
| 19274 | /* If window not full width, must redo its mode line | 19277 | /* If window not full width, must redo its mode line |
| 19275 | if (a) the window to its side is being redone and | 19278 | 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) | |||
| 19288 | || window_wants_header_line (w) | 19291 | || window_wants_header_line (w) |
| 19289 | || window_wants_tab_line (w))) | 19292 | || window_wants_tab_line (w))) |
| 19290 | { | 19293 | { |
| 19294 | ptrdiff_t count1 = SPECPDL_INDEX (); | ||
| 19291 | 19295 | ||
| 19296 | specbind (Qinhibit_quit, Qt); | ||
| 19292 | display_mode_lines (w); | 19297 | display_mode_lines (w); |
| 19298 | unbind_to (count1, Qnil); | ||
| 19293 | 19299 | ||
| 19294 | /* If mode line height has changed, arrange for a thorough | 19300 | /* If mode line height has changed, arrange for a thorough |
| 19295 | immediate redisplay using the correct mode line height. */ | 19301 | immediate redisplay using the correct mode line height. */ |
| @@ -19337,7 +19343,7 @@ redisplay_window (Lisp_Object window, bool just_this_one_p) | |||
| 19337 | finish_menu_bars: | 19343 | finish_menu_bars: |
| 19338 | 19344 | ||
| 19339 | /* When we reach a frame's selected window, redo the frame's menu | 19345 | /* When we reach a frame's selected window, redo the frame's menu |
| 19340 | bar and the frame's title. */ | 19346 | bar, tool bar, tab-bar, and the frame's title. */ |
| 19341 | if (update_mode_line | 19347 | if (update_mode_line |
| 19342 | && EQ (FRAME_SELECTED_WINDOW (f), window)) | 19348 | && EQ (FRAME_SELECTED_WINDOW (f), window)) |
| 19343 | { | 19349 | { |
| @@ -25428,8 +25434,8 @@ redisplay_mode_lines (Lisp_Object window, bool force) | |||
| 25428 | } | 25434 | } |
| 25429 | 25435 | ||
| 25430 | 25436 | ||
| 25431 | /* Display the mode and/or header line of window W. Value is the | 25437 | /* Display the mode and/or header line of window W. Value is the sum |
| 25432 | sum number of mode lines and header lines displayed. */ | 25438 | number of mode lines, header lines, and tab lines actually displayed. */ |
| 25433 | 25439 | ||
| 25434 | static int | 25440 | static int |
| 25435 | display_mode_lines (struct window *w) | 25441 | display_mode_lines (struct window *w) |
| @@ -27009,7 +27015,7 @@ decode_mode_spec (struct window *w, register int c, int field_width, | |||
| 27009 | Lisp_Object val = Qnil; | 27015 | Lisp_Object val = Qnil; |
| 27010 | 27016 | ||
| 27011 | if (STRINGP (curdir)) | 27017 | if (STRINGP (curdir)) |
| 27012 | val = call1 (intern ("file-remote-p"), curdir); | 27018 | val = safe_call1 (intern ("file-remote-p"), curdir); |
| 27013 | 27019 | ||
| 27014 | val = unbind_to (count, val); | 27020 | val = unbind_to (count, val); |
| 27015 | 27021 | ||