unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Zaretskii <eliz@gnu.org>
Cc: larsi@gnus.org, aaronjensen@gmail.com, emacs-devel@gnu.org
Subject: Re: A whole lotta auto-saving going
Date: Wed, 13 Jan 2021 17:25:39 -0500	[thread overview]
Message-ID: <jwvpn28xz1x.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <jwvsg775qkk.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 11 Jan 2021 13:00:33 -0500")

>> 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;
 }
 
 




  parent reply	other threads:[~2021-01-13 22:25 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-06 22:05 A whole lotta auto-saving going Aaron Jensen
2021-01-07 12:24 ` Lars Ingebrigtsen
2021-01-07 15:21   ` Stefan Monnier
2021-01-08 14:05     ` Aaron Jensen
2021-01-08 14:19       ` Aaron Jensen
2021-01-10 11:10         ` Lars Ingebrigtsen
2021-01-10 15:08           ` Aaron Jensen
2021-01-10 15:24             ` Lars Ingebrigtsen
2021-01-10 17:27               ` Eli Zaretskii
2021-01-10 17:38                 ` Stefan Monnier
2021-01-11  4:23                   ` Stefan Monnier
2021-01-11 15:04                     ` Eli Zaretskii
2021-01-11 16:00                       ` Stefan Monnier
2021-01-11 16:54                         ` Eli Zaretskii
2021-01-11 18:00                           ` Stefan Monnier
2021-01-12 14:58                             ` Eli Zaretskii
2021-01-12 15:18                               ` Stefan Monnier
2021-01-13 22:25                             ` Stefan Monnier [this message]
2021-01-18 16:06                               ` Lars Ingebrigtsen
2021-01-10 17:18           ` Stefan Monnier
2021-01-10 18:34             ` T.V Raman
2021-01-10 18:54               ` Aaron Jensen
2021-01-12 16:02                 ` T.V Raman via Emacs development discussions.
2021-01-07 14:55 ` Eli Zaretskii
2021-01-10 11:09   ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvpn28xz1x.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=aaronjensen@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).