emacs-devel
[Top][All Lists]
Advanced

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

Re: A whole lotta auto-saving going


From: Stefan Monnier
Subject: Re: A whole lotta auto-saving going
Date: Wed, 13 Jan 2021 17:25:39 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>> It's a different use case, and I don't think we saw any adverse
>> effects there from the removal of the buffer-switch "event".
>> Are there any adverse effects?
>
> The fact that echo-keystrokes were displayed earlier than expected was
> not a serious issue, so I didn't bother to report it.  But I do think
> it's an adverse effect.

Also, in the old code with BUFFER_SWITCH_EVENT there was the same
side-effect, i.e. process output would interrupt the `sit_for` of
echo-keystrokes just like my patch does.

IOW, I don't think my patch is The Right Thing (because that would
involve making `sit_for` loop until the end of the timeout as long as
there's no pending input), but it brings back the old behavior in a "bug
compatible" way.

So unless there's any objection I plan to push the patch below in the
coming days,


        Stefan


diff --git a/src/dispnew.c b/src/dispnew.c
index 36a6dd8a09..e603c67136 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -6049,7 +6049,14 @@ DEFUN ("sleep-for", Fsleep_for, Ssleep_for, 1, 2, 0,
    READING is true if reading input.
    If DISPLAY_OPTION is >0 display process output while waiting.
    If DISPLAY_OPTION is >1 perform an initial redisplay before waiting.
-*/
+
+   Returns a boolean Qt if we waited the full time and returns Qnil if the
+   wait was interrupted by incoming process output or keyboard events.
+
+   FIXME: When `wait_reading_process_output` returns early because of
+   process output, instead of returning nil we should loop and wait some
+   more (i.e. until either there's pending input events or the timeout
+   expired).  */
 
 Lisp_Object
 sit_for (Lisp_Object timeout, bool reading, int display_option)
@@ -6110,8 +6117,9 @@ sit_for (Lisp_Object timeout, bool reading, int 
display_option)
   gobble_input ();
 #endif
 
-  wait_reading_process_output (sec, nsec, reading ? -1 : 1, do_display,
-                              Qnil, NULL, 0);
+  int nbytes
+    = 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
@@ -6120,7 +6128,7 @@ sit_for (Lisp_Object timeout, bool reading, int 
display_option)
        buffer to start with).  */
     set_buffer_internal (XBUFFER (XWINDOW (selected_window)->contents));
 
-  return detect_input_pending () ? Qnil : Qt;
+  return (nbytes > 0 || detect_input_pending ()) ? Qnil : Qt;
 }
 
 




reply via email to

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