unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Get key-binding for a command and print key binding in kbd syntax
Date: Thu, 09 Feb 2023 12:44:16 +0100	[thread overview]
Message-ID: <878rh7m5bj.fsf@gmail.com> (raw)
In-Reply-To: 878rh72ie4.fsf@gnu.org

>>>>> On Thu, 09 Feb 2023 12:09:14 +0100, Tassilo Horn <tsdh@gnu.org> said:
    Tassilo> Oh, not quite.  Right now, there's for example a "[C]ompose a new mail"
    Tassilo> text where the C also has a keymap property which would invoke the
    Tassilo> respective command on mouse-2 and RET.  `substitute-command-keys'
    Tassilo> doesn't allow doing that out of the box.  So one would need to iterate
    Tassilo> over occurrences of the help-key-binding face afterwards, translate back
    Tassilo> to the command and add a keymap property.

    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

    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.

Robert
-- 




  reply	other threads:[~2023-02-09 11:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-09  8:33 Get key-binding for a command and print key binding in kbd syntax Tassilo Horn
2023-02-09 10:28 ` Robert Pluim
2023-02-09 10:50   ` Tassilo Horn
2023-02-09 11:09     ` Tassilo Horn
2023-02-09 11:44       ` Robert Pluim [this message]
2023-02-09 11:58         ` Tassilo Horn
2023-02-09 12:20           ` Robert Pluim
2023-02-09 12:22             ` Tassilo Horn
2023-02-09 13:46               ` Robert Pluim
2023-02-09 14:10                 ` Tassilo Horn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878rh7m5bj.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).