unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: rrt@sc3d.org, 19547@debbugs.gnu.org
Subject: bug#19547: Patch for this bug
Date: Sun, 27 Nov 2016 07:52:28 +0100	[thread overview]
Message-ID: <87zikl8leb.fsf@gmail.com> (raw)
In-Reply-To: <83h96u3d07.fsf@gnu.org>


Eli Zaretskii <eliz@gnu.org> writes:

> You can do that with a 'switch' in C, or, better, with a C array that
> holds the symbols and their corresponding C event_kind values, like
> this:
>
>  struct event_value {
>    Lisp_Object event_symbol;
>    enum event_kind event_kind;
>  };
>  static struct event_value symbol_to_kind[] = {
>    { Qfocus_in, FOCUS_IN_EVENT },
>    { Qhelp, HELP_EVENT },
>    { Qiconify, ICONIFY_EVENT },
>    ...
>  };
>
> Then, for each symbol, you can find the corresponding event value by
> walking the array until you find a match.

I finally wrote a patch for keyboard.c which is compiling without error,
I used switch because I still not understanding how to use the code
above (seems that is approach is too advanced for my skills compared to
the usage of switch).
The patch seems to work fine with helm, though i didn't test with our
bug (https://github.com/emacs-helm/helm/issues/1157), but I now don't
know where to initialize our variable (while-no-input-ignore-events), I
just setq it in scratch buffer after starting helm with a minimal
installation (script emacs-helm.sh).

Here the patch (please look at it carefully this is the first C code I write):

diff --git a/src/keyboard.c b/src/keyboard.c
index 65938a5..3caf506 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -3567,14 +3567,22 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event,
 #endif	/* subprocesses */
     }
 
+  Lisp_Object ignore_event;
+
+  switch (event->kind)
+    {
+    case FOCUS_IN_EVENT: ignore_event = Qfocus_in;
+    case FOCUS_OUT_EVENT: ignore_event = Qfocus_out;
+    case HELP_EVENT: ignore_event = Qhelp;
+    case ICONIFY_EVENT: ignore_event = Qiconify;
+    case DEICONIFY_EVENT: ignore_event = Qdeiconify;
+    case SELECTION_REQUEST_EVENT: ignore_event = Qselection_request;
+    }
+
   /* 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,12 @@ 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;
+    /* = listn (Qfocus_in, Qfocus_out, Qhelp, Qiconify, Qdeiconify, Qselection_request); */
 }
 
 void


Thanks.

-- 
Thierry





  parent reply	other threads:[~2016-11-27  6:52 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-09 15:46 bug#19547: 25.0.50; throw-on-input "fires" when switching workspace Michael Heerdegen
2015-01-09 19:59 ` Eli Zaretskii
2015-01-09 21:48   ` Michael Heerdegen
2015-01-10  9:14     ` Eli Zaretskii
2015-01-09 23:33 ` Stefan Monnier
2015-01-10  0:00   ` Michael Heerdegen
2015-01-10  1:26     ` Michael Heerdegen
2015-01-10  9:12       ` Eli Zaretskii
2015-01-10 22:24         ` Michael Heerdegen
2015-01-11  1:47           ` Stefan Monnier
2015-01-20  2:46             ` Michael Heerdegen
2015-01-20  3:43               ` Eli Zaretskii
2015-01-29 19:59                 ` Michael Heerdegen
2015-01-31  8:38                   ` Eli Zaretskii
2015-02-01 14:25                     ` Michael Heerdegen
2015-02-01 15:54                       ` Eli Zaretskii
2015-02-01 17:21                         ` Michael Heerdegen
2015-02-01 17:35                           ` Eli Zaretskii
2015-10-13 10:50                             ` Michael Heerdegen
2015-12-10 20:14                               ` John Wiegley
2015-12-10 22:05                                 ` Michael Heerdegen
2015-12-10 23:01                                   ` John Wiegley
     [not found]                                     ` <83fuz98gre.fsf@gnu.org>
2015-12-11 10:17                                       ` Thierry Volpiatto
     [not found]                                         ` <838u518d32.fsf@gnu.org>
2015-12-11 14:22                                           ` Michael Heerdegen
     [not found]                                             ` <83r3it6m5u.fsf@gnu.org>
2015-12-26  0:37                                               ` Michael Heerdegen
2015-12-26 10:01                                                 ` Eli Zaretskii
2015-01-10  9:18     ` Eli Zaretskii
2016-11-08 18:28 ` bug#19547: Patch for this bug Reuben Thomas
2016-11-08 20:40   ` Eli Zaretskii
2016-11-08 22:20     ` Reuben Thomas
2016-11-09 19:43       ` Eli Zaretskii
2016-11-09 22:03         ` Reuben Thomas
2016-11-10 17:46           ` Eli Zaretskii
2016-11-25 17:10             ` Thierry Volpiatto
2016-11-26  7:40               ` Eli Zaretskii
2016-11-26  8:39                 ` Andreas Schwab
2016-11-26  9:02                   ` Eli Zaretskii
2016-11-26 18:50                 ` Thierry Volpiatto
2016-11-27  6:52                 ` Thierry Volpiatto [this message]
2016-11-27 14:07                   ` npostavs
2016-11-27 14:53                     ` Thierry Volpiatto
2016-11-27 15:54                       ` Eli Zaretskii
2016-11-27 17:59                         ` Thierry Volpiatto
2016-11-27 18:40                           ` Eli Zaretskii
2016-11-27 19:03                             ` Thierry Volpiatto
2016-11-27 19:39                               ` Eli Zaretskii
2016-11-27 19:54                                 ` Thierry Volpiatto
2016-11-27 20:06                                   ` Eli Zaretskii
2016-11-27 20:53                                     ` Thierry Volpiatto
2016-11-30 20:27                                     ` Thierry Volpiatto
2016-12-01  3:28                                       ` Eli Zaretskii
2017-06-11 22:03                                         ` npostavs
2016-11-27 18:42                           ` npostavs
2016-11-27 19:08                             ` Thierry Volpiatto
2016-11-27  7:16                 ` Thierry Volpiatto
2016-11-27 18:05               ` Reuben Thomas
2016-11-27 18:29                 ` Thierry Volpiatto
2016-11-27 21:10                   ` Johan Bockgård
2016-11-28  6:00                     ` Thierry Volpiatto

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=87zikl8leb.fsf@gmail.com \
    --to=thierry.volpiatto@gmail.com \
    --cc=19547@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=rrt@sc3d.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).