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:09:14 +0100
User-agent: mu4e 1.9.19; emacs 30.0.50

Tassilo Horn <tsdh@gnu.org> writes:

>>     Tassilo> So the question is: how do you get the key(s) for a
>>     Tassilo> command?  `where-is-internal' looks promising giving
>>     Tassilo> ([106] [menu-bar mu4e Search\ maildir]) where 106 is the
>>     Tassilo> char ?j.  If that's the right way, is numeric vector
>>     Tassilo> vs. vector of symbols the right way to distinguish key
>>     Tassilo> bindings from menu items?
>>
>> `substitute-command-keys'
>
> Oh, yeah, I've forgotten about that one.  I think that will do
> everything I need in one go.

Oh, not quite.  Right now, there's for example a "[C]ompose a new mail"
text where the C also has a keymap property which would invoke the
respective command on mouse-2 and RET.  `substitute-command-keys'
doesn't allow doing that out of the box.  So one would need to iterate
over occurrences of the help-key-binding face afterwards, translate back
to the command and add a keymap property.

How do I lookup a command for the printed key description?

  (keymap-lookup nil "C-c C-c")
  ;=> message-send-and-exit

works but is too new to be used for packages supporting older emacsen.
Is

  (lookup-key (current-local-map) (kbd "C-c C-c"))

the right incarnation?

Bye,
Tassilo  



reply via email to

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