diff options
| author | Stefan Monnier | 2021-01-15 22:38:52 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2021-01-15 22:38:52 -0500 |
| commit | 5d6817086d6485bc6e3dde054d877c0759656ddd (patch) | |
| tree | 4f8c0ddbf4437aee265776f7a1f801821a869707 /src | |
| parent | f45be48ddbde00610e1e08fca6590dcf24a4e1b5 (diff) | |
| download | emacs-5d6817086d6485bc6e3dde054d877c0759656ddd.tar.gz emacs-5d6817086d6485bc6e3dde054d877c0759656ddd.zip | |
* src/dispnew.c (sit_for): Return nil when interrupted by process output
Before adbb4eacc2a984c0fc0b65ec761368fd9067d6c5,
`read_and_dispose_of_process_output` called
`record_asynch_buffer_change` which added "artificial" input events
(in the form of BUFFER_SWITCH_EVENTs), causing sit_for to return
Qnil when interrupted by process output. Without those BUFFER_SWITCH_EVENTs,
sit_for now tends to return Qt when interrupted by process output
making `read_char` believe that we've waited the whole timeout,
As consequence incoming process output tended to cause premature
auto-saving of files (sometimes right after almost every key press).
This patch recovers the previous behavior, which is not ideal
(incoming process output can delay auto-save indefinitely), but has
been good enough for many years.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dispnew.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/dispnew.c b/src/dispnew.c index 36a6dd8a091..e603c671363 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -6049,7 +6049,14 @@ additional wait period, in milliseconds; this is for backwards compatibility. | |||
| 6049 | READING is true if reading input. | 6049 | READING is true if reading input. |
| 6050 | If DISPLAY_OPTION is >0 display process output while waiting. | 6050 | If DISPLAY_OPTION is >0 display process output while waiting. |
| 6051 | If DISPLAY_OPTION is >1 perform an initial redisplay before waiting. | 6051 | If DISPLAY_OPTION is >1 perform an initial redisplay before waiting. |
| 6052 | */ | 6052 | |
| 6053 | Returns a boolean Qt if we waited the full time and returns Qnil if the | ||
| 6054 | wait was interrupted by incoming process output or keyboard events. | ||
| 6055 | |||
| 6056 | FIXME: When `wait_reading_process_output` returns early because of | ||
| 6057 | process output, instead of returning nil we should loop and wait some | ||
| 6058 | more (i.e. until either there's pending input events or the timeout | ||
| 6059 | expired). */ | ||
| 6053 | 6060 | ||
| 6054 | Lisp_Object | 6061 | Lisp_Object |
| 6055 | sit_for (Lisp_Object timeout, bool reading, int display_option) | 6062 | sit_for (Lisp_Object timeout, bool reading, int display_option) |
| @@ -6110,8 +6117,9 @@ sit_for (Lisp_Object timeout, bool reading, int display_option) | |||
| 6110 | gobble_input (); | 6117 | gobble_input (); |
| 6111 | #endif | 6118 | #endif |
| 6112 | 6119 | ||
| 6113 | wait_reading_process_output (sec, nsec, reading ? -1 : 1, do_display, | 6120 | int nbytes |
| 6114 | Qnil, NULL, 0); | 6121 | = wait_reading_process_output (sec, nsec, reading ? -1 : 1, do_display, |
| 6122 | Qnil, NULL, 0); | ||
| 6115 | 6123 | ||
| 6116 | if (reading && curbuf_eq_winbuf) | 6124 | if (reading && curbuf_eq_winbuf) |
| 6117 | /* Timers and process filters/sentinels may have changed the selected | 6125 | /* Timers and process filters/sentinels may have changed the selected |
| @@ -6120,7 +6128,7 @@ sit_for (Lisp_Object timeout, bool reading, int display_option) | |||
| 6120 | buffer to start with). */ | 6128 | buffer to start with). */ |
| 6121 | set_buffer_internal (XBUFFER (XWINDOW (selected_window)->contents)); | 6129 | set_buffer_internal (XBUFFER (XWINDOW (selected_window)->contents)); |
| 6122 | 6130 | ||
| 6123 | return detect_input_pending () ? Qnil : Qt; | 6131 | return (nbytes > 0 || detect_input_pending ()) ? Qnil : Qt; |
| 6124 | } | 6132 | } |
| 6125 | 6133 | ||
| 6126 | 6134 | ||