help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get key-binding for a command and print key binding in kbd syntax


From: Tassilo Horn
Subject: Re: Get key-binding for a command and print key binding in kbd syntax
Date: Thu, 09 Feb 2023 12:58:37 +0100
User-agent: mu4e 1.9.19; emacs 30.0.50

Robert Pluim <rpluim@gmail.com> writes:

>     Tassilo> How do I lookup a command for the printed key description?
>
>     Tassilo>   (keymap-lookup nil "C-c C-c")
>     Tassilo>   ;=> message-send-and-exit
>
>     Tassilo> works but is too new to be used for packages supporting
>     Tassilo> older emacsen.
>
> I think `keymap-lookup' will be in `compat' when emacs-29 comes out

AFAIK, mu4e doesn't use the compat library (yet) since you cannot
install it from ELPA or some other archive anyhow given that it's
tightly coupled to mu mail indexer, i.e., the C++ and the elisp parts
must be compatible.

>     Tassilo> Is
>
>     Tassilo>   (lookup-key (current-local-map) (kbd "C-c C-c"))
>
>     Tassilo> the right incarnation?
>
> For a 'keymap property? Probably
>
>     (get-char-property (point) 'keymap)
>
> is needed to get the right map. `current-local-map' is for the buffer.

No, no.  I've meant that with substitute-command-keys I have the correct
key-descriptions in the buffer with help-key-binding face.  However, I
would also like to have them clickable so I think I need to "parse" the
buffer and add keymap properties to the text having the help-key-binding
face.

So for example, there is the text "[j]ump to some maildir" where the j
is a key-description (recognizable by its help-key-binding face), I need
to translate back the j to the command mu4e-search-maildir in order to
add a keymap where RET and mouse-2 are bound to that command.

Bye,
Tassilo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]