Subject: Re: bug#71648: 30.0.50; Allow which-key to report on translation bindings

From: Justin Burkett <[email-masked]>
Date: Wed, 19 Jun 2024 11:48:01 -0400

On Wed, Jun 19, 2024 at 11:34 AM Eli Zaretskii <[email-masked]> wrote:
>
> > From: Justin Burkett <[email-masked]>
> > Date: Wed, 19 Jun 2024 11:09:36 -0400
> > Cc: Robert Pluim <[email-masked]>, Jeremy Bryant <[email-masked]>, [email-masked]
> >
> > The purpose of which-key was to show the commands that are available
> > following an incomplete key sequence. If I understand correctly, these
> > maps don't hold commands and anyway would be processed before
> > which-key "sees" the current incomplete key sequence.
>
> Everything in Emacs is a command.  The specific sequences Robert was
> talking about eventually insert characters, but they are still a
> sequence of key events.  So I'm not sure I understand how you
> distinguish between them and what fundamental differences do you see.
> Would you like to elaborate on how and why do you perceive these to be
> different?
>
> > If I understand correctly, if "C-d x" translates to "C-c x" then
> > which-key I believe would see the sequence "C-c x" and find the
> > bindings following that sequence. I'm not sure how or why we would
> > want to display the information that "C-d x" translates to "C-c x".
>
> I don't think this case is the most important or the most interesting.

The purpose of the example was to show my (mis)understanding of how
these maps work. I was under the impression from the info manual that
translation keymaps map key sequences to other key sequences which are
then mapped to "commands" (which might be just text to insert).
Quoting the info manual:

"When the ‘read-key-sequence’ function reads a key sequence (*note Key
Sequence Input::), it uses “translation keymaps” to translate certain
event sequences into others.  The translation keymaps are
‘input-decode-map’, ‘local-function-key-map’, and ‘key-translation-map’
(in order of priority).

   Translation keymaps have the same structure as other keymaps, but are
used differently: they specify translations to make while reading key
sequences, rather than bindings for complete key sequences.  As each key
sequence is read, it is checked against each translation keymap.  If one
of the translation keymaps binds K to a vector V, then whenever K
appears as a sub-sequence _anywhere_ in a key sequence, that
sub-sequence is replaced with the events in V."

This reads to me like translation keymaps don't yield "commands" they
act at an intermediate level.

In any event, Robert's example was helpful, and I think that
information would be useful to include in which-key.