From unknown Mon Aug 18 08:56:47 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#19746 <19746@debbugs.gnu.org> To: bug#19746 <19746@debbugs.gnu.org> Subject: Status: 25.0.50; Emacs should treat synthetic up-events gracefully Reply-To: bug#19746 <19746@debbugs.gnu.org> Date: Mon, 18 Aug 2025 15:56:47 +0000 retitle 19746 25.0.50; Emacs should treat synthetic up-events gracefully reassign 19746 emacs submitter 19746 David Kastrup severity 19746 wishlist tag 19746 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 02 14:15:35 2015 Received: (at submit) by debbugs.gnu.org; 2 Feb 2015 19:15:35 +0000 Received: from localhost ([127.0.0.1]:60623 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YIMT8-0007jV-Ov for submit@debbugs.gnu.org; Mon, 02 Feb 2015 14:15:35 -0500 Received: from eggs.gnu.org ([208.118.235.92]:47181) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YIMT6-0007jG-7h for submit@debbugs.gnu.org; Mon, 02 Feb 2015 14:15:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YIMSv-00077J-ST for submit@debbugs.gnu.org; Mon, 02 Feb 2015 14:15:26 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:33706) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIMSv-00077F-Oh for submit@debbugs.gnu.org; Mon, 02 Feb 2015 14:15:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIMSt-0000O0-Gw for bug-gnu-emacs@gnu.org; Mon, 02 Feb 2015 14:15:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YIMSn-00075w-Ra for bug-gnu-emacs@gnu.org; Mon, 02 Feb 2015 14:15:19 -0500 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:46186) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIMSn-00075s-Mu for bug-gnu-emacs@gnu.org; Mon, 02 Feb 2015 14:15:13 -0500 Received: from localhost ([127.0.0.1]:53362 helo=lola) by fencepost.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIMSm-0005Cy-Oz for bug-gnu-emacs@gnu.org; Mon, 02 Feb 2015 14:15:13 -0500 Received: by lola (Postfix, from userid 1000) id 167D8E04E9; Mon, 2 Feb 2015 20:15:12 +0100 (CET) From: David Kastrup To: bug-gnu-emacs@gnu.org Subject: 25.0.50; Emacs should treat synthetic up-events gracefully Date: Mon, 02 Feb 2015 20:15:12 +0100 Message-ID: <8761bk3z27.fsf@fencepost.gnu.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) --=-=-= Content-Type: text/plain Emacs' mouse event code deals with the up- modifier (bit 0 in the modifier mask) by converting it to click- or drag-events. This happens at the C level. However, when synthesizing events for things like Midi keyboards (basically computerized music instruments), it makes sense _not_ to convert an up-key event to either a drag or click event since usually the down-event is a principal event of its own: basically the "importance relation" of down- and up-events is reversed for those kinds of keys as compared to mouse buttons and this reflects in what kind of event one would want representing it. This patch allows the keymap machinery to treat the up- modifier in a manner analog to the down-modifier even though Emacs will not (yet) natively generate up-events itself. However, it will allow sensible behavior for such events being pushed into unread-command-events. It has been proposed on the Emacs developer list on and had some comments amended at . However, there was an additional request at to change one comment in read_key_sequence to actions not matching the code in read_key_sequence but rather happening in make_lispy_event. The explanation why this change would be inappropriate in was after an additional exchange "resolved" with an ad hominem attack in . Further private communication led to no results. In order to at least provide users in need of this functionality with a referenceable issue report (and possibly get someone else to apply the patch), I am submitting the patch against current master here. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Let-input-queue-deal-gracefully-with-up-events.patch >From f2b6ebd4401ce9258a644a29060449b0579a59e9 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Wed, 28 Jan 2015 11:53:54 +0100 Subject: [PATCH] Let input queue deal gracefully with up-events * keyboard.c (apply_modifiers_uncached, parse_solitary_modifier) (parse_modifiers_uncached): React gracefully to "up-" modifiers: those may easily be injected by user-level Lisp code. (read_key_sequence): Discard unbound up-events like unbound down-events: they are even more likely only relevant for special purposes. While Emacs will not produce up-events on its own currently (those are converted to drag or click events before being converted to Lisp-readable structures), the input queue can be made to contain them by synthesizing events to `unread-command-events'. This patch makes Emacs deal consistently with such events. --- src/ChangeLog | 9 +++++++++ src/keyboard.c | 34 +++++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index d3f667e..d83f1e5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2015-01-28 David Kastrup + + * keyboard.c (apply_modifiers_uncached, parse_solitary_modifier) + (parse_modifiers_uncached): React gracefully to "up-" modifiers: + those may easily be injected by user-level Lisp code. + (read_key_sequence): Discard unbound up-events like unbound + down-events: they are even more likely only relevant for special + purposes. + 2015-02-01 Martin Rudalics * xdisp.c (Fwindow_text_pixel_size): Add optional argument BUFFER. diff --git a/src/keyboard.c b/src/keyboard.c index 1176d70..ff200d4 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -6215,6 +6215,10 @@ parse_modifiers_uncached (Lisp_Object symbol, ptrdiff_t *modifier_end) case 't': MULTI_LETTER_MOD (triple_modifier, "triple", 6); break; + + case 'u': + MULTI_LETTER_MOD (up_modifier, "up", 2); + break; #undef MULTI_LETTER_MOD } @@ -6262,16 +6266,18 @@ apply_modifiers_uncached (int modifiers, char *base, int base_len, int base_len_ /* Since BASE could contain nulls, we can't use intern here; we have to use Fintern, which expects a genuine Lisp_String, and keeps a reference to it. */ - char new_mods[sizeof "A-C-H-M-S-s-down-drag-double-triple-"]; + char new_mods[sizeof "A-C-H-M-S-s-up-down-drag-double-triple-"]; int mod_len; { char *p = new_mods; - /* Only the event queue may use the `up' modifier; it should always - be turned into a click or drag event before presented to lisp code. */ - if (modifiers & up_modifier) - emacs_abort (); + /* Mouse events should not exhibit the `up' modifier; it should + always be turned into a click or drag event before being + presented to lisp code. And there should not be more than one + of up/down/click/drag anyway. But since Lisp events can be + synthesized, we don't take exception to unexpected + combinations */ if (modifiers & alt_modifier) { *p++ = 'A'; *p++ = '-'; } if (modifiers & ctrl_modifier) { *p++ = 'C'; *p++ = '-'; } @@ -6281,6 +6287,7 @@ apply_modifiers_uncached (int modifiers, char *base, int base_len, int base_len_ if (modifiers & super_modifier) { *p++ = 's'; *p++ = '-'; } if (modifiers & double_modifier) p = stpcpy (p, "double-"); if (modifiers & triple_modifier) p = stpcpy (p, "triple-"); + if (modifiers & up_modifier) p = stpcpy (p, "up-"); if (modifiers & down_modifier) p = stpcpy (p, "down-"); if (modifiers & drag_modifier) p = stpcpy (p, "drag-"); /* The click modifier is denoted by the absence of other modifiers. */ @@ -6400,8 +6407,7 @@ DEFUN ("internal-event-symbol-parse-modifiers", Fevent_symbol_parse_modifiers, BASE must be unmodified. This is like apply_modifiers_uncached, but uses BASE's - Qmodifier_cache property, if present. It also builds - Qevent_symbol_elements properties, since it has that info anyway. + Qmodifier_cache property, if present. apply_modifiers copies the value of BASE's Qevent_kind property to the modified symbol. */ @@ -6747,6 +6753,10 @@ parse_solitary_modifier (Lisp_Object symbol) MULTI_LETTER_MOD (triple_modifier, "triple", 6); break; + case 'u': + MULTI_LETTER_MOD (up_modifier, "up", 2); + break; + #undef SINGLE_LETTER_MOD #undef MULTI_LETTER_MOD } @@ -9454,14 +9464,16 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, Drags reduce to clicks. Double-clicks reduce to clicks. Triple-clicks reduce to double-clicks, then to clicks. - Down-clicks are eliminated. + Up/Down-clicks are eliminated. Double-downs reduce to downs, then are eliminated. Triple-downs reduce to double-downs, then to downs, then are eliminated. */ - if (modifiers & (down_modifier | drag_modifier + if (modifiers & (up_modifier | down_modifier + | drag_modifier | double_modifier | triple_modifier)) { - while (modifiers & (down_modifier | drag_modifier + while (modifiers & (up_modifier | down_modifier + | drag_modifier | double_modifier | triple_modifier)) { Lisp_Object new_head, new_click; @@ -9473,7 +9485,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, modifiers &= ~drag_modifier; else { - /* Dispose of this `down' event by simply jumping + /* Dispose of this `up/down' event by simply jumping back to replay_key, to get another event. Note that if this event came from mock input, -- 2.1.0 --=-=-= Content-Type: text/plain In GNU Emacs 25.0.50.2 (i686-pc-linux-gnu, GTK+ Version 3.12.2) of 2014-12-19 on lola Repository revision: c683666bcd0f0675ba72894a4a6374cf15849385 Windowing system distributor `The X.Org Foundation', version 11.0.11600000 System Description: Ubuntu 14.10 Configured using: `configure --without-toolkit-scroll-bars' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB Important settings: value of $LC_MONETARY: en_US.UTF-8 value of $LC_NUMERIC: en_US.UTF-8 value of $LC_TIME: en_US.UTF-8 value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: Fundamental Minor modes in effect: shell-dirtrack-mode: t TeX-PDF-mode: t diff-auto-refine-mode: t desktop-save-mode: t minibuffer-electric-default-mode: t tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t Recent messages: No more unread articles Making completion list... Found `patches, sending' in Concept Index. (Only match) Quit Are you sure you want to quit reading news? (y or n) y (No changes need to be saved) Saving /home/dak/.newsrc.eld... Saving file /home/dak/.newsrc.eld... Wrote /home/dak/.newsrc.eld Saving /home/dak/.newsrc.eld...done Load-path shadows: None found. Features: (shadow emacsbug sgml-mode nndoc tramp-cache tramp-sh tramp tramp-compat tramp-loaddefs trampver shell pcomplete gnus-dup help-mode debug thingatpt pp rfc2368 sendmail nnir flow-fill shr dom subr-x pcase browse-url mm-archive mule-util sort smiley gnus-cite mail-extr gnus-async gnus-bcklg gnus-kill qp gnus-ml disp-table pop3 nndir nndraft nnmh gnutls network-stream nsm auth-source cl-macs gv eieio eieio-core starttls nnml nnfolder nnnil gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime password-cache dig mailcap nntp gnus-cache gnus-sum gnus-group gnus-undo gnus-start gnus-cloud nnimap nnmail mail-source tls utf7 netrc nnoo parse-time gnus-spec gnus-int gnus-range message format-spec rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev gmm-utils mailheader gnus-win sh-script smie executable make-mode smerge-mode scheme latexenc nxml-uchnm rng-xsd xsd-regexp rng-cmpct rng-nxml rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns nxml-mode nxml-outln nxml-rap nxml-util nxml-glyph nxml-enc xmltok dired-x dired python json tex-info texinfo autorevert filenotify cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs lilypond-mode compile comint ansi-color ring bug-reference add-log preview prv-emacs reftex-dcr reftex-auc reftex reftex-vars tex-bar tex-buf toolbar-x noutline outline font-latex byte-opt bytecomp byte-compile cl-extra cconv latex edmacro kmacro tex-style tex dbus xml crm vc-git diff-mode easy-mmode jka-compr info easymenu package epg-config advice desktop frameset minibuf-eldef gnus gnus-ems nnheader gnus-util mail-utils mm-util help-fns mail-prsvr wid-edit cl-loaddefs cl-lib cus-start cus-load preview-latex tex-site auto-loads server time-date tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process dbusbind gfilenotify dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs) Memory information: ((conses 8 739868 45106) (symbols 24 52766 375) (miscs 20 1596 1711) (strings 16 120678 18300) (string-bytes 1 3817797) (vectors 8 47334) (vector-slots 4 1796732 49030) (floats 8 385 606) (intervals 28 63060 1020) (buffers 520 276) (heap 1024 63553 15724)) -- David Kastrup --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 04 10:18:06 2015 Received: (at control) by debbugs.gnu.org; 4 Feb 2015 15:18:06 +0000 Received: from localhost ([127.0.0.1]:34010 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YJ1iQ-0001wS-74 for submit@debbugs.gnu.org; Wed, 04 Feb 2015 10:18:06 -0500 Received: from fencepost.gnu.org ([208.118.235.10]:49148 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YJ1iN-0001wH-BK for control@debbugs.gnu.org; Wed, 04 Feb 2015 10:18:04 -0500 Received: from localhost ([127.0.0.1]:56455 helo=lola) by fencepost.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJ1iM-0008NW-Pz for control@debbugs.gnu.org; Wed, 04 Feb 2015 10:18:03 -0500 Received: by lola (Postfix, from userid 1000) id 6976CE8B9A; Wed, 4 Feb 2015 16:18:02 +0100 (CET) From: David Kastrup To: control@debbugs.gnu.org Subject: Body Date: Wed, 04 Feb 2015 16:18:02 +0100 Message-ID: <87egq51z9x.fsf@fencepost.gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) tags 19746 patch severity 19746 wishlist -- David Kastrup From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 14 11:03:30 2015 Received: (at 19746-done) by debbugs.gnu.org; 14 Aug 2015 15:03:30 +0000 Received: from localhost ([127.0.0.1]:55852 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZQGW2-0007C2-5G for submit@debbugs.gnu.org; Fri, 14 Aug 2015 11:03:30 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46976) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZQGW0-0007Bv-JP for 19746-done@debbugs.gnu.org; Fri, 14 Aug 2015 11:03:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZQGVz-0001Ci-7n for 19746-done@debbugs.gnu.org; Fri, 14 Aug 2015 11:03:28 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:58631) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZQGVz-0001CW-1f for 19746-done@debbugs.gnu.org; Fri, 14 Aug 2015 11:03:27 -0400 Received: from localhost ([127.0.0.1]:44217 helo=lola) by fencepost.gnu.org with esmtp (Exim 4.82) (envelope-from ) id 1ZQGVy-0003Se-H1 for 19746-done@debbugs.gnu.org; Fri, 14 Aug 2015 11:03:26 -0400 Received: by lola (Postfix, from userid 1000) id EA13AE07DB; Fri, 14 Aug 2015 17:03:25 +0200 (CEST) From: David Kastrup To: 19746-done@debbugs.gnu.org Subject: Date: Fri, 14 Aug 2015 17:03:23 +0200 Message-ID: <87r3n5nc90.fsf@fencepost.gnu.org> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::e X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: 19746-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) -- David Kastrup From unknown Mon Aug 18 08:56:47 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 12 Sep 2015 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator