diff options
| -rw-r--r-- | doc/lispref/commands.texi | 6 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/subr.el | 4 | ||||
| -rw-r--r-- | src/keyboard.c | 27 |
4 files changed, 36 insertions, 5 deletions
diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi index 46756d0ddd6..c4de5299ce9 100644 --- a/doc/lispref/commands.texi +++ b/doc/lispref/commands.texi | |||
| @@ -2917,6 +2917,12 @@ like this: | |||
| 2917 | @end example | 2917 | @end example |
| 2918 | @end defmac | 2918 | @end defmac |
| 2919 | 2919 | ||
| 2920 | @defvar while-no-input-ignore-events | ||
| 2921 | This variable allow setting which special events @code{while-no-input} | ||
| 2922 | should ignore. It is a list of symbols. | ||
| 2923 | |||
| 2924 | @end defvar | ||
| 2925 | |||
| 2920 | @defun discard-input | 2926 | @defun discard-input |
| 2921 | @cindex flushing input | 2927 | @cindex flushing input |
| 2922 | @cindex discarding input | 2928 | @cindex discarding input |
| @@ -610,6 +610,10 @@ function 'check-declare-errmsg' has been removed. | |||
| 610 | 610 | ||
| 611 | * Lisp Changes in Emacs 26.1 | 611 | * Lisp Changes in Emacs 26.1 |
| 612 | 612 | ||
| 613 | ** New variable 'while-no-input-ignore-events' which allow | ||
| 614 | setting which special events 'while-no-input' should ignore. | ||
| 615 | It is a list of symbols. | ||
| 616 | |||
| 613 | ** New function 'undo-amalgamate-change-group' to get rid of | 617 | ** New function 'undo-amalgamate-change-group' to get rid of |
| 614 | undo-boundaries between two states. | 618 | undo-boundaries between two states. |
| 615 | 619 | ||
diff --git a/lisp/subr.el b/lisp/subr.el index eb9ab98c4b8..73f7f3e0d12 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -3335,6 +3335,10 @@ is allowed once again. (Immediately, if `inhibit-quit' is nil.)" | |||
| 3335 | ;; that intends to handle the quit signal next time. | 3335 | ;; that intends to handle the quit signal next time. |
| 3336 | (eval '(ignore nil))))) | 3336 | (eval '(ignore nil))))) |
| 3337 | 3337 | ||
| 3338 | ;; Don't throw `throw-on-input' on those events by default. | ||
| 3339 | (setq while-no-input-ignore-events | ||
| 3340 | '(focus-in focus-out help iconify deiconify selection-request)) | ||
| 3341 | |||
| 3338 | (defmacro while-no-input (&rest body) | 3342 | (defmacro while-no-input (&rest body) |
| 3339 | "Execute BODY only as long as there's no pending input. | 3343 | "Execute BODY only as long as there's no pending input. |
| 3340 | If input arrives, that ends the execution of BODY, | 3344 | If input arrives, that ends the execution of BODY, |
diff --git a/src/keyboard.c b/src/keyboard.c index 65938a5eb56..6d509dd42be 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -3567,14 +3567,22 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event, | |||
| 3567 | #endif /* subprocesses */ | 3567 | #endif /* subprocesses */ |
| 3568 | } | 3568 | } |
| 3569 | 3569 | ||
| 3570 | Lisp_Object ignore_event = Qnil; | ||
| 3571 | |||
| 3572 | switch (event->kind) | ||
| 3573 | { | ||
| 3574 | case FOCUS_IN_EVENT: ignore_event = Qfocus_in; break; | ||
| 3575 | case FOCUS_OUT_EVENT: ignore_event = Qfocus_out; break; | ||
| 3576 | case HELP_EVENT: ignore_event = Qhelp; break; | ||
| 3577 | case ICONIFY_EVENT: ignore_event = Qiconify; break; | ||
| 3578 | case DEICONIFY_EVENT: ignore_event = Qdeiconify; break; | ||
| 3579 | case SELECTION_REQUEST_EVENT: ignore_event = Qselection_request; break; | ||
| 3580 | } | ||
| 3581 | |||
| 3570 | /* If we're inside while-no-input, and this event qualifies | 3582 | /* If we're inside while-no-input, and this event qualifies |
| 3571 | as input, set quit-flag to cause an interrupt. */ | 3583 | as input, set quit-flag to cause an interrupt. */ |
| 3572 | if (!NILP (Vthrow_on_input) | 3584 | if (!NILP (Vthrow_on_input) |
| 3573 | && event->kind != FOCUS_IN_EVENT | 3585 | && !NILP (Fmemq (ignore_event, Vwhile_no_input_ignore_events))) |
| 3574 | && event->kind != FOCUS_OUT_EVENT | ||
| 3575 | && event->kind != HELP_EVENT | ||
| 3576 | && event->kind != ICONIFY_EVENT | ||
| 3577 | && event->kind != DEICONIFY_EVENT) | ||
| 3578 | { | 3586 | { |
| 3579 | Vquit_flag = Vthrow_on_input; | 3587 | Vquit_flag = Vthrow_on_input; |
| 3580 | /* If we're inside a function that wants immediate quits, | 3588 | /* If we're inside a function that wants immediate quits, |
| @@ -11164,6 +11172,10 @@ syms_of_keyboard (void) | |||
| 11164 | DEFSYM (Qiconify_frame, "iconify-frame"); | 11172 | DEFSYM (Qiconify_frame, "iconify-frame"); |
| 11165 | DEFSYM (Qmake_frame_visible, "make-frame-visible"); | 11173 | DEFSYM (Qmake_frame_visible, "make-frame-visible"); |
| 11166 | DEFSYM (Qselect_window, "select-window"); | 11174 | DEFSYM (Qselect_window, "select-window"); |
| 11175 | DEFSYM (Qhelp, "help"); | ||
| 11176 | DEFSYM (Qiconify, "iconify"); | ||
| 11177 | DEFSYM (Qdeiconify, "deiconify"); | ||
| 11178 | DEFSYM (Qselection_request, "selection-request"); | ||
| 11167 | { | 11179 | { |
| 11168 | int i; | 11180 | int i; |
| 11169 | 11181 | ||
| @@ -11822,6 +11834,11 @@ signals. */); | |||
| 11822 | 11834 | ||
| 11823 | /* Create the initial keyboard. Qt means 'unset'. */ | 11835 | /* Create the initial keyboard. Qt means 'unset'. */ |
| 11824 | initial_kboard = allocate_kboard (Qt); | 11836 | initial_kboard = allocate_kboard (Qt); |
| 11837 | |||
| 11838 | DEFVAR_LISP ("while-no-input-ignore-events", | ||
| 11839 | Vwhile_no_input_ignore_events, | ||
| 11840 | doc: /* Ignored events from while-no-input. */); | ||
| 11841 | Vwhile_no_input_ignore_events = Qnil; | ||
| 11825 | } | 11842 | } |
| 11826 | 11843 | ||
| 11827 | void | 11844 | void |