From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ruijie Yu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#60530: 28.2; Add tools to find keymaps that bind a given command Date: Mon, 20 Feb 2023 15:07:09 +0800 Message-ID: References: <9D2761CB-E158-4D8A-876B-CE1AE0F9ACEA@toadstyle.org> Reply-To: Ruijie Yu Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40289"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.8.13; emacs 29.0.60 Cc: 60530@debbugs.gnu.org To: Sean Devlin Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 20 08:31:31 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pU0e2-000ALL-Sw for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 20 Feb 2023 08:31:30 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU0dd-0001ZI-Cy; Mon, 20 Feb 2023 02:31:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pU0db-0001Y4-1q for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2023 02:31:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pU0da-0002K2-Jj for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2023 02:31:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pU0da-0007E9-8N for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2023 02:31:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ruijie Yu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 20 Feb 2023 07:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60530 X-GNU-PR-Package: emacs Original-Received: via spool by 60530-submit@debbugs.gnu.org id=B60530.167687823027743 (code B ref 60530); Mon, 20 Feb 2023 07:31:02 +0000 Original-Received: (at 60530) by debbugs.gnu.org; 20 Feb 2023 07:30:30 +0000 Original-Received: from localhost ([127.0.0.1]:50358 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pU0d4-0007DP-7T for submit@debbugs.gnu.org; Mon, 20 Feb 2023 02:30:30 -0500 Original-Received: from netyu.xyz ([152.44.41.246]:36664 helo=mail.netyu.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pU0d1-0007DG-Fp for 60530@debbugs.gnu.org; Mon, 20 Feb 2023 02:30:28 -0500 Original-Received: from fw.net.yu.netyu.xyz ( [222.248.4.98]) by netyu.xyz (OpenSMTPD) with ESMTPSA id b0bfc680 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 20 Feb 2023 07:30:25 +0000 (UTC) In-reply-to: <9D2761CB-E158-4D8A-876B-CE1AE0F9ACEA@toadstyle.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:256131 Archived-At: Sean Devlin 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 > 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