From: Eli Zaretskii Date: Sat, 29 Sep 2018 07:11:08 +0000 (+0300) Subject: Avoid returning early in 'while-no-input' due to subprocesses X-Git-Tag: emacs-26.1.90~123 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d416109f06ab3910e3f49176185154a5179b6354;p=emacs.git Avoid returning early in 'while-no-input' due to subprocesses * src/keyboard.c (kbd_buffer_store_buffered_event): Support also the internal buffer-switch events. (syms_of_keyboard) : New DEFSYM. * lisp/subr.el (while-no-input-ignore-events): Ignore 'buffer-switch' events. Reported by Michael Heerdegen . * etc/NEWS: Mention the change in behavior of 'while-no-input' --- diff --git a/etc/NEWS b/etc/NEWS index 578b9b8d956..bfd7db016f2 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -123,6 +123,16 @@ be removed prior using the changed 'shadow-*' commands. The old name is an alias of the new name. Future Emacs version will obsolete it. +--- +** 'while-no-input' does not return due to input from subprocesses. +Input that arrived from subprocesses while some code executed inside +the 'while-no-input' form injected an internal buffer-switch event +that counted as input and would cause 'while-no-input' to return, +perhaps prematurely. These buffer-switch events are now by default +ignored by 'while-no-input'; if you need to get the old behavior, +remove 'buffer-switch' from the list of events in +'while-no-input-ignore-events'. + * Lisp Changes in Emacs 26.2 diff --git a/lisp/subr.el b/lisp/subr.el index 7582b6cdb85..59f6949b211 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -3542,7 +3542,7 @@ is allowed once again. (Immediately, if `inhibit-quit' is nil.)" ;; Don't throw `throw-on-input' on those events by default. (setq while-no-input-ignore-events '(focus-in focus-out help-echo iconify-frame - make-frame-visible selection-request)) + make-frame-visible selection-request buffer-switch)) (defmacro while-no-input (&rest body) "Execute BODY only as long as there's no pending input. diff --git a/src/keyboard.c b/src/keyboard.c index 1da5ac088d3..0d56ea3f7ac 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -3569,6 +3569,7 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event, case ICONIFY_EVENT: ignore_event = Qiconify_frame; break; case DEICONIFY_EVENT: ignore_event = Qmake_frame_visible; break; case SELECTION_REQUEST_EVENT: ignore_event = Qselection_request; break; + case BUFFER_SWITCH_EVENT: ignore_event = Qbuffer_switch; break; default: ignore_event = Qnil; break; } @@ -11104,6 +11105,8 @@ syms_of_keyboard (void) /* Menu and tool bar item parts. */ DEFSYM (Qmenu_enable, "menu-enable"); + DEFSYM (Qbuffer_switch, "buffer-switch"); + #ifdef HAVE_NTGUI DEFSYM (Qlanguage_change, "language-change"); DEFSYM (Qend_session, "end-session");