GNU bug report logs - #76669
read_key_sequence discards events without attempting remapping

Previous Next

Package: emacs;

Reported by: Daniel Colascione <dancol <at> dancol.org>

Date: Sat, 1 Mar 2025 23:36:02 UTC

Severity: normal

Full log


Message #14 received at 76669 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Daniel Colascione <dancol <at> dancol.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 76669 <at> debbugs.gnu.org
Subject: Re: bug#76669: read_key_sequence discards events without attempting
 remapping
Date: Sun, 02 Mar 2025 09:23:39 -0500
>>> Suppose we want to use local-function-key-map to translate
>>> s-<down-mouse-3> to <down-mouse-3>.  If we don't have a concrete binding
>>> for s-<down-mouse-3>, we never attempt to translate it: instead,
>>> read_key_sequence discards the down event and skips right to
>>> s-<mouse-3>, which we *can* translate.

Hmm... to be honest, I'm surprised that this is what happens, because my
recollection of the code was that dropping down/double/drag (and shift)
is done "as late as possible".

Maybe this is just a bug?

>> I think it's ambiguous which one should come first: the discarding of
>> 'down' modifier or translation via that map.  The ELisp manual says:

Given that translation is "customizable" it's desirable to go through
translation before deciding to drop `down`, but it's also desirable to
go through translation after dropping `down`.

FWIW, I have several times wished the `function-key-map`-style "remap if
there's no binding" was applied repeatedly.

> Wouldn't it be simpler and more powerful to get the modifier-munging
> stuff out of the main read_key_sequence loop and implement the down
> event dropping in access_keymap_keyremap?

That would prevent applying remapping after the `down` thingy
was dropped.

In my wildest dreams, `read_key_sequence` has an `input-fallback-map`
which is applied repeatedly, and keymaps can be functions so that they
can do things like remap anything that looks like `FOO-mouse-1` to
`FOO-mouse-2` (without having to list the hundreds of possible FOO) or
remap anything that looks like `down-FOO` to `FOO`.
Then `read_key_sequence` doesn't treat shift and `down` specially,
instead that can be moved out to `input-fallback-map`.

But, yeah, that still leaves open the question of whether we should drop
`shift` before we drop `down` or the reverse, and whether the
`FOO-mouse-1` to `FOO-mouse-2` remapping should happen before or after
dropping `down`.  The only "principled" way to solve this problem,
AFAICT, would be to consider those remapping and returning all the
possibilities (as a set of possible keysequences) and then when we do
the corresponding key lookup, we'd have to decide what to do if there's
more than one binding for those keysequences.


        Stefan





This bug report was last modified 159 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.