]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow configuring which event throw-on-input should ignore (bug#19547).
authorThierry Volpiatto <thierry.volpiatto@gmail.com>
Sun, 27 Nov 2016 08:31:58 +0000 (09:31 +0100)
committerThierry Volpiatto <thierry.volpiatto@gmail.com>
Sun, 27 Nov 2016 20:48:07 +0000 (21:48 +0100)
* src/keyboard.c (kbd_buffer_store_buffered_event):
Translate event to corresponding symbol from `while-no-input-ignore-events`
and check them with Fmemq.
(syms_of_keyboard): Declare new lisp variable `while-no-input-ignore-events`
and its symbols.

* lisp/subr.el (while-no-input-ignore-events): Add default values.

* doc/lispref/commands.texi (Event Input Misc):
Document while-no-input-ignore-events.
* etc/NEWS: Same.

doc/lispref/commands.texi
etc/NEWS
lisp/subr.el
src/keyboard.c

index 46756d0ddd6a761c2610929e2b26a9c813a8eb22..c4de5299ce9eb5abd8683430f04461b72fe789d0 100644 (file)
@@ -2917,6 +2917,12 @@ like this:
 @end example
 @end defmac
 
+@defvar while-no-input-ignore-events
+This variable allow setting which special events @code{while-no-input}
+should ignore.  It is a list of symbols.
+
+@end defvar
+
 @defun discard-input
 @cindex flushing input
 @cindex discarding input
index 0b73e5df7d0930f367be0cb9580dd77b25f0a14e..cbce027e6d4006f432d258e387dc5f19007cbff1 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -610,6 +610,10 @@ function 'check-declare-errmsg' has been removed.
 \f
 * Lisp Changes in Emacs 26.1
 
+** New variable 'while-no-input-ignore-events' which allow
+setting which special events 'while-no-input' should ignore.
+It is a list of symbols.
+
 ** New function 'undo-amalgamate-change-group' to get rid of
 undo-boundaries between two states.
 
index eb9ab98c4b85603c763747226f48fde6bd5bbb63..73f7f3e0d12a6af13db826dc92a98c8e0b126fa7 100644 (file)
@@ -3335,6 +3335,10 @@ is allowed once again.  (Immediately, if `inhibit-quit' is nil.)"
           ;; that intends to handle the quit signal next time.
           (eval '(ignore nil)))))
 
+;; Don't throw `throw-on-input' on those events by default.
+(setq while-no-input-ignore-events
+      '(focus-in focus-out help iconify deiconify selection-request))
+
 (defmacro while-no-input (&rest body)
   "Execute BODY only as long as there's no pending input.
 If input arrives, that ends the execution of BODY,
index 65938a5eb56e610ca4249d7e68ca33760b10a9ed..6d509dd42be4467653a0349f9d667664989446ff 100644 (file)
@@ -3567,14 +3567,22 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event,
 #endif /* subprocesses */
     }
 
+  Lisp_Object ignore_event = Qnil;
+
+  switch (event->kind)
+    {
+    case FOCUS_IN_EVENT: ignore_event = Qfocus_in; break;
+    case FOCUS_OUT_EVENT: ignore_event = Qfocus_out; break;
+    case HELP_EVENT: ignore_event = Qhelp; break;
+    case ICONIFY_EVENT: ignore_event = Qiconify; break;
+    case DEICONIFY_EVENT: ignore_event = Qdeiconify; break;
+    case SELECTION_REQUEST_EVENT: ignore_event = Qselection_request; break;
+    }
+
   /* If we're inside while-no-input, and this event qualifies
      as input, set quit-flag to cause an interrupt.  */
   if (!NILP (Vthrow_on_input)
-      && event->kind != FOCUS_IN_EVENT
-      && event->kind != FOCUS_OUT_EVENT
-      && event->kind != HELP_EVENT
-      && event->kind != ICONIFY_EVENT
-      && event->kind != DEICONIFY_EVENT)
+      && !NILP (Fmemq (ignore_event, Vwhile_no_input_ignore_events)))
     {
       Vquit_flag = Vthrow_on_input;
       /* If we're inside a function that wants immediate quits,
@@ -11164,6 +11172,10 @@ syms_of_keyboard (void)
   DEFSYM (Qiconify_frame, "iconify-frame");
   DEFSYM (Qmake_frame_visible, "make-frame-visible");
   DEFSYM (Qselect_window, "select-window");
+  DEFSYM (Qhelp, "help");
+  DEFSYM (Qiconify, "iconify");
+  DEFSYM (Qdeiconify, "deiconify");
+  DEFSYM (Qselection_request, "selection-request");
   {
     int i;
 
@@ -11822,6 +11834,11 @@ signals.  */);
 
   /* Create the initial keyboard.  Qt means 'unset'.  */
   initial_kboard = allocate_kboard (Qt);
+
+  DEFVAR_LISP ("while-no-input-ignore-events",
+               Vwhile_no_input_ignore_events,
+               doc: /* Ignored events from while-no-input.  */);
+  Vwhile_no_input_ignore_events = Qnil;
 }
 
 void