all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ruijie Yu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Sean Devlin <spd@toadstyle.org>
Cc: 60530@debbugs.gnu.org
Subject: bug#60530: 28.2; Add tools to find keymaps that bind a given command
Date: Mon, 20 Feb 2023 15:07:09 +0800	[thread overview]
Message-ID: <sdv8rgsn69o.fsf@fw.net.yu> (raw)
In-Reply-To: <9D2761CB-E158-4D8A-876B-CE1AE0F9ACEA@toadstyle.org>


Sean Devlin <spd@toadstyle.org> writes:

> Hi folks,
>
> There is a third-party package "helpful"
> (https://github.com/Wilfred/helpful) that provides (in their words) "an
> alternative to the built-in Emacs help that provides much more
> contextual information".
>
> One nice feature their describe-command replacement provides is a list
> of bindings for the given command for all known keymaps. For example,
> for find-file it might generate a list like the following:
>
> ctl-x-map C-f
> embark-become-file+buffer-map f
> embark-file-map RET
> embark-file-map f
> global-map <open>
> global-map C-x C-f
> term-raw-map C-c C-f
>
> [...]
>
> It's nice to know exactly which keymaps contain a binding. It gives you
> a better idea of where best to tweak a configuration, and it can give
> you new ideas about how and where a command might be used.

I saw this message long ago, but recently I came across a situation
where I wanted to know if a command was bound in *some* keymap whose
name I didn't know, and this would be quite a helpful feature for me
personally (pun intended).

> I looked in helpful.el, and they use some non-trivial logic to generate
> their list. I think this functionality should come built-in with Emacs.

Looking in their source, I think (with some handwaving) the logic boils
down to iterating over all keymap objects inside `obarray', and checking
whether the command of interest is actively bound (that is, not
shadowed, etc) in each keymap.  Some other things are happening inside
helpful.el as well, probably regarding other components in the helpful
buffer.

> I think Emacs should provide low-level functions to generate a list of
> bindings similar to the above and a command to describe the bindings. It
> might also be nice to expose the information in describe-command like
> helpful.el does.

If there is interest, maybe I can take a look inside help-fns.el and see
if I can figure out how to add new contents in the *Help* buffer, and
then try to come up with a patchset, with the goal of (correctly and)
concisely implement command-keymap lookups without depending on dash and
f.  This might take a while, though, as some other things of mine are
prioritized over coding ATM.

In addition, this feature probably needs to be guarded behind a boolean
defcustom flag so that people who don't want this addition don't pay for
the cost.

Thoughts?

--
Best,


RY





  reply	other threads:[~2023-02-20  7:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-03 22:30 bug#60530: 28.2; Add tools to find keymaps that bind a given command Sean Devlin
2023-02-20  7:07 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-02-20 11:54   ` Eli Zaretskii
2023-02-20 12:01     ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-20 13:09       ` Eli Zaretskii
2023-02-20 13:44         ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors

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

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

  git send-email \
    --in-reply-to=sdv8rgsn69o.fsf@fw.net.yu \
    --to=bug-gnu-emacs@gnu.org \
    --cc=60530@debbugs.gnu.org \
    --cc=ruijie@netyu.xyz \
    --cc=spd@toadstyle.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.