emacs-diffs
[Top][All Lists]
Advanced

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

master ccb3eff 2/2: * src/dispnew.c (sit_for): Fix bug#45292


From: Stefan Monnier
Subject: master ccb3eff 2/2: * src/dispnew.c (sit_for): Fix bug#45292
Date: Wed, 23 Dec 2020 18:32:02 -0500 (EST)

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

    * src/dispnew.c (sit_for): Fix bug#45292
    
    When reading, prefer staying in the selected-window over preserving
    the current-buffer.
---
 src/dispnew.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/dispnew.c b/src/dispnew.c
index 89dd32a..e0a6476 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -6057,6 +6057,8 @@ sit_for (Lisp_Object timeout, bool reading, int 
display_option)
   intmax_t sec;
   int nsec;
   bool do_display = display_option > 0;
+  bool curbuf_eq_winbuf
+    = (current_buffer == XBUFFER (XWINDOW (selected_window)->contents));
 
   swallow_events (do_display);
 
@@ -6111,6 +6113,13 @@ sit_for (Lisp_Object timeout, bool reading, int 
display_option)
   wait_reading_process_output (sec, nsec, reading ? -1 : 1, do_display,
                               Qnil, NULL, 0);
 
+  if (reading && curbuf_eq_winbuf)
+    /* Timers and process filters/sentinels may have changed the selected
+       window (e.g. in response to a connection from emacsclient), in which
+       case we should follow it (unless we weren't in the selected-window's
+       buffer to start with).  */
+    set_buffer_internal (XBUFFER (XWINDOW (selected_window)->contents));
+
   return detect_input_pending () ? Qnil : Qt;
 }
 



reply via email to

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