GNU bug report logs - #60530
28.2; Add tools to find keymaps that bind a given command

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Sean Devlin <spd@HIDDEN>; dated Tue, 3 Jan 2023 22:32:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 60530 <at> debbugs.gnu.org:


Received: (at 60530) by debbugs.gnu.org; 20 Feb 2023 14:18:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 20 09:18:18 2023
Received: from localhost ([127.0.0.1]:51111 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pU6zh-0006Yi-Rd
	for submit <at> debbugs.gnu.org; Mon, 20 Feb 2023 09:18:18 -0500
Received: from netyu.xyz ([152.44.41.246]:45656 helo=mail.netyu.xyz)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ruijie@HIDDEN>) id 1pU6zg-0006Ya-Qp
 for 60530 <at> debbugs.gnu.org; Mon, 20 Feb 2023 09:18:17 -0500
Received: from fw.net.yu.netyu.xyz (<unknown> [222.248.4.98])
 by netyu.xyz (OpenSMTPD) with ESMTPSA id 7f703913
 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); 
 Mon, 20 Feb 2023 14:18:15 +0000 (UTC)
References: <9D2761CB-E158-4D8A-876B-CE1AE0F9ACEA@HIDDEN>
 <sdv8rgsn69o.fsf@HIDDEN> <83a618wo10.fsf@HIDDEN>
 <sdvzg98le1h.fsf@HIDDEN> <83ilfwv5yz.fsf@HIDDEN>
User-agent: mu4e 1.8.13; emacs 29.0.60
From: Ruijie Yu <ruijie@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#60530: 28.2; Add tools to find keymaps that bind a given
 command
Date: Mon, 20 Feb 2023 21:44:31 +0800
In-reply-to: <83ilfwv5yz.fsf@HIDDEN>
Message-ID: <sdvv8jwl8tl.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60530
Cc: spd@HIDDEN, 60530 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)


Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Ruijie Yu <ruijie@HIDDEN>
>> Cc: spd@HIDDEN, 60530 <at> debbugs.gnu.org
>> Date: Mon, 20 Feb 2023 20:01:27 +0800
>>
>>
>> Eli Zaretskii <eliz@HIDDEN> writes:
>>
>> >> Cc: 60530 <at> debbugs.gnu.org
>> >> Date: Mon, 20 Feb 2023 15:07:09 +0800
>> >> From:  Ruijie Yu via "Bug reports for GNU Emacs,
>> >>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
>> >>
>> >> 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).
>> >
>> > Isn't that what where-is and/or where-is-internal already do?
>>
>> No, not quite.  The functions where-is{,-internal} only look for
>> *currently active keymaps*, whereas my intention was to look for all
>> keybinds for the specified command, be it active or not.
>
> But that's impossible in principle, because loading some package could
> produce a binding for a command, and you don't know which packages
> will be loaded into a session before they are actually loaded.
>
> Or what am I missing?

My idea is to only use the "current state" (whatever that might mean)
for searching for keybinds, and that criterion should exclude things
like autoload, as the key isn't bound until the package is properly
loaded.

So IMO, the only difference between `where-is' and this new function
would be this: instead of looking for active keymaps, the new function
looks for all existing (named) keymaps from `obarray' -- and do the same
action of scanning over the list of keymaps and figure out what
information to show to the user.

But anyways, this can absolutely be simply user-local code, and doesn't
have to live inside emacs.git.

>> The following is my reason to want this feature.  I use pyim, an input
>> method that shows candidate words in a small frame (which I believe is
>> called posframe?), which has `pyim-mode-map' enabled.  Then, while
>> typing, I want to know how to call the `pyim-next-page' command without
>> going into pyim source.
>>
>> If I type M-x where-is, this frame disappears, and I am dropped back
>> into the editing buffer, which does not have `pyim-mode-map' enabled.
>> Hence, `where-is' does not show anything bound for `pyim-next-page',
>> because it indeed is not bound globally.  FTR, C-h b does not work
>> either.
>
> If what where-is does doesn't suit your needs for reasons of its UI or
> how it switches buffers, you could extract (parts of) its code and
> make a similar function which presents the results in a way that
> doesn't interrupt your workflow.  My point in mentioning the existing
> commands is that they already show how to find bindings for an
> arbitrary command, so you could reuse some or all of that code for
> your purposes (which sound very similar to me).

I understand and agree.  See above for further comments.

--
Best,


RY




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60530; Package emacs. Full text available.

Message received at 60530 <at> debbugs.gnu.org:


Received: (at 60530) by debbugs.gnu.org; 20 Feb 2023 13:09:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 20 08:09:26 2023
Received: from localhost ([127.0.0.1]:50949 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pU5v4-0002FO-8F
	for submit <at> debbugs.gnu.org; Mon, 20 Feb 2023 08:09:26 -0500
Received: from eggs.gnu.org ([209.51.188.92]:52166)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pU5v2-0002FC-Sa
 for 60530 <at> debbugs.gnu.org; Mon, 20 Feb 2023 08:09:25 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pU5ux-000547-8v; Mon, 20 Feb 2023 08:09:19 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=HfnH5V+E1IJ0r2cgbS36d+mxM1onOeGmD1fPKsQgq3g=; b=BPN8XVNUQzE0
 vq86xcjI+IgtSXbdMZJJ98+907q4jZkuFCcWXuvjhKBp42ncqtZZAl5Oooi72Se+GddovvKdmaunf
 RsQf3sivl+OxhPN8GGz1AFya1bK67RwWw530oyxb6qrpqw3BzzsFfic49/61peo4JyC9pzLTi2d3G
 EFtzrPkkrJOqfdoceA1AgsKjEsgwXRsfTniigd7PIFhvxbn+HimdE7VMdJtYvj0HhY6q79rMAh36E
 J8eesjhS1ptgobwU0h7lpnodvTaUMpeVMHjT8fcSntIpks0n4t7EYW5pvYHqKc3LR5jbah2mxDIP6
 G2IrHcTJ0zaAPz5C6ItcHQ==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pU5uu-00057b-3i; Mon, 20 Feb 2023 08:09:18 -0500
Date: Mon, 20 Feb 2023 15:09:24 +0200
Message-Id: <83ilfwv5yz.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Ruijie Yu <ruijie@HIDDEN>
In-Reply-To: <sdvzg98le1h.fsf@HIDDEN> (message from Ruijie Yu on Mon, 20
 Feb 2023 20:01:27 +0800)
Subject: Re: bug#60530: 28.2; Add tools to find keymaps that bind a given
 command
References: <9D2761CB-E158-4D8A-876B-CE1AE0F9ACEA@HIDDEN>
 <sdv8rgsn69o.fsf@HIDDEN> <83a618wo10.fsf@HIDDEN>
 <sdvzg98le1h.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 60530
Cc: spd@HIDDEN, 60530 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Ruijie Yu <ruijie@HIDDEN>
> Cc: spd@HIDDEN, 60530 <at> debbugs.gnu.org
> Date: Mon, 20 Feb 2023 20:01:27 +0800
> 
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> >> Cc: 60530 <at> debbugs.gnu.org
> >> Date: Mon, 20 Feb 2023 15:07:09 +0800
> >> From:  Ruijie Yu via "Bug reports for GNU Emacs,
> >>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> >>
> >> 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).
> >
> > Isn't that what where-is and/or where-is-internal already do?
> 
> No, not quite.  The functions where-is{,-internal} only look for
> *currently active keymaps*, whereas my intention was to look for all
> keybinds for the specified command, be it active or not.

But that's impossible in principle, because loading some package could
produce a binding for a command, and you don't know which packages
will be loaded into a session before they are actually loaded.

Or what am I missing?

> The following is my reason to want this feature.  I use pyim, an input
> method that shows candidate words in a small frame (which I believe is
> called posframe?), which has `pyim-mode-map' enabled.  Then, while
> typing, I want to know how to call the `pyim-next-page' command without
> going into pyim source.
> 
> If I type M-x where-is, this frame disappears, and I am dropped back
> into the editing buffer, which does not have `pyim-mode-map' enabled.
> Hence, `where-is' does not show anything bound for `pyim-next-page',
> because it indeed is not bound globally.  FTR, C-h b does not work
> either.

If what where-is does doesn't suit your needs for reasons of its UI or
how it switches buffers, you could extract (parts of) its code and
make a similar function which presents the results in a way that
doesn't interrupt your workflow.  My point in mentioning the existing
commands is that they already show how to find bindings for an
arbitrary command, so you could reuse some or all of that code for
your purposes (which sound very similar to me).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60530; Package emacs. Full text available.

Message received at 60530 <at> debbugs.gnu.org:


Received: (at 60530) by debbugs.gnu.org; 20 Feb 2023 12:25:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 20 07:25:31 2023
Received: from localhost ([127.0.0.1]:50808 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pU5EZ-00073i-KS
	for submit <at> debbugs.gnu.org; Mon, 20 Feb 2023 07:25:31 -0500
Received: from netyu.xyz ([152.44.41.246]:59200 helo=mail.netyu.xyz)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ruijie@HIDDEN>) id 1pU5EW-00073a-LB
 for 60530 <at> debbugs.gnu.org; Mon, 20 Feb 2023 07:25:30 -0500
Received: from fw.net.yu.netyu.xyz (<unknown> [222.248.4.98])
 by netyu.xyz (OpenSMTPD) with ESMTPSA id ba0512a8
 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); 
 Mon, 20 Feb 2023 12:25:25 +0000 (UTC)
References: <9D2761CB-E158-4D8A-876B-CE1AE0F9ACEA@HIDDEN>
 <sdv8rgsn69o.fsf@HIDDEN> <83a618wo10.fsf@HIDDEN>
User-agent: mu4e 1.8.13; emacs 29.0.60
From: Ruijie Yu <ruijie@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#60530: 28.2; Add tools to find keymaps that bind a given
 command
Date: Mon, 20 Feb 2023 20:01:27 +0800
In-reply-to: <83a618wo10.fsf@HIDDEN>
Message-ID: <sdvzg98le1h.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60530
Cc: spd@HIDDEN, 60530 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)


Eli Zaretskii <eliz@HIDDEN> writes:

>> Cc: 60530 <at> debbugs.gnu.org
>> Date: Mon, 20 Feb 2023 15:07:09 +0800
>> From:  Ruijie Yu via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
>>
>> 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).
>
> Isn't that what where-is and/or where-is-internal already do?

No, not quite.  The functions where-is{,-internal} only look for
*currently active keymaps*, whereas my intention was to look for all
keybinds for the specified command, be it active or not.

The following is my reason to want this feature.  I use pyim, an input
method that shows candidate words in a small frame (which I believe is
called posframe?), which has `pyim-mode-map' enabled.  Then, while
typing, I want to know how to call the `pyim-next-page' command without
going into pyim source.

If I type M-x where-is, this frame disappears, and I am dropped back
into the editing buffer, which does not have `pyim-mode-map' enabled.
Hence, `where-is' does not show anything bound for `pyim-next-page',
because it indeed is not bound globally.  FTR, C-h b does not work
either.

Similar situations can occur in other popup behaviors with temporary
keybinds, such as lsp-ui package (github.com/emacs-lsp/lsp-ui).

--
Best,


RY




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60530; Package emacs. Full text available.

Message received at 60530 <at> debbugs.gnu.org:


Received: (at 60530) by debbugs.gnu.org; 20 Feb 2023 11:54:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 20 06:54:11 2023
Received: from localhost ([127.0.0.1]:50721 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pU4kF-0006De-0W
	for submit <at> debbugs.gnu.org; Mon, 20 Feb 2023 06:54:11 -0500
Received: from eggs.gnu.org ([209.51.188.92]:43474)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pU4kC-0006DO-WE
 for 60530 <at> debbugs.gnu.org; Mon, 20 Feb 2023 06:54:10 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pU4k7-0005Vd-KX; Mon, 20 Feb 2023 06:54:03 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=YrHpT4hBzK0Q5bk1MF6b2FDvZ4JurgwxuJ01sTIsPdk=; b=S/5Zs1FRsyih
 4FTq9iVjEvYGT1qsCQi0KWNzsTaTODEqIlRxCmEl9TO5ziOO8XCbEH+tnyN3wwzNrsJQZsMPzOQlE
 CUTMbzrKXFeJADoFARIQAHK2dazGV31DK6aycUmvR62uWQHFrnnzo3S4/m6qYIhvmmS92Xm8kmwtH
 PdcU1hvhHEhCwBqLR/7ywMAz/5jc89+1ExWCleTXOryWTgHIZYvt4oQYNgPAP7iR+WSm8nHcLEjm1
 /VCJDiQwDs31Mrc/ik2CLwBJ5yguZgxxLez3U9x34Vl0coim7cBf0L+n+yHciKaoEsgO5NYgPN24+
 PCi6O3aeEOIT5jHgQJz9pQ==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pU4k0-0001s2-1x; Mon, 20 Feb 2023 06:54:03 -0500
Date: Mon, 20 Feb 2023 13:54:03 +0200
Message-Id: <83a618wo10.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Ruijie Yu <ruijie@HIDDEN>
In-Reply-To: <sdv8rgsn69o.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#60530: 28.2;
 Add tools to find keymaps that bind a given command
References: <9D2761CB-E158-4D8A-876B-CE1AE0F9ACEA@HIDDEN>
 <sdv8rgsn69o.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 60530
Cc: spd@HIDDEN, 60530 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: 60530 <at> debbugs.gnu.org
> Date: Mon, 20 Feb 2023 15:07:09 +0800
> From:  Ruijie Yu via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> 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).

Isn't that what where-is and/or where-is-internal already do?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60530; Package emacs. Full text available.

Message received at 60530 <at> debbugs.gnu.org:


Received: (at 60530) by debbugs.gnu.org; 20 Feb 2023 07:30:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 20 02:30:30 2023
Received: from localhost ([127.0.0.1]:50358 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pU0d4-0007DP-7T
	for submit <at> debbugs.gnu.org; Mon, 20 Feb 2023 02:30:30 -0500
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 <ruijie@HIDDEN>) id 1pU0d1-0007DG-Fp
 for 60530 <at> debbugs.gnu.org; Mon, 20 Feb 2023 02:30:28 -0500
Received: from fw.net.yu.netyu.xyz (<unknown> [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)
References: <9D2761CB-E158-4D8A-876B-CE1AE0F9ACEA@HIDDEN>
User-agent: mu4e 1.8.13; emacs 29.0.60
From: Ruijie Yu <ruijie@HIDDEN>
To: Sean Devlin <spd@HIDDEN>
Subject: Re: bug#60530: 28.2; Add tools to find keymaps that bind a given
 command
Date: Mon, 20 Feb 2023 15:07:09 +0800
In-reply-to: <9D2761CB-E158-4D8A-876B-CE1AE0F9ACEA@HIDDEN>
Message-ID: <sdv8rgsn69o.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60530
Cc: 60530 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)


Sean Devlin <spd@HIDDEN> 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




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60530; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 3 Jan 2023 22:31:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 03 17:31:15 2023
Received: from localhost ([127.0.0.1]:47001 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pCpoR-0001ue-Df
	for submit <at> debbugs.gnu.org; Tue, 03 Jan 2023 17:31:15 -0500
Received: from lists.gnu.org ([209.51.188.17]:56854)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <spd@HIDDEN>) id 1pCpoP-0001uR-L3
 for submit <at> debbugs.gnu.org; Tue, 03 Jan 2023 17:31:14 -0500
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 <spd@HIDDEN>) id 1pCpoP-0006jp-F2
 for bug-gnu-emacs@HIDDEN; Tue, 03 Jan 2023 17:31:13 -0500
Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <spd@HIDDEN>) id 1pCpoK-0000Jg-R5
 for bug-gnu-emacs@HIDDEN; Tue, 03 Jan 2023 17:31:11 -0500
Received: by mail-qt1-x82f.google.com with SMTP id v14so22975765qtq.3
 for <bug-gnu-emacs@HIDDEN>; Tue, 03 Jan 2023 14:31:05 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=toadstyle-org.20210112.gappssmtp.com; s=20210112;
 h=to:date:message-id:subject:mime-version:content-transfer-encoding
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=OGNrG4iZcR6YW3JkxTF1iCj4y7Qu3fNPRjMkHA1d3p0=;
 b=cIvOu2ztPlXQYCRae47Nj2kZXAJQtCbfnJZSBNxmwv3O5+EebbqsVhWkaIelc8d+sT
 UAQMea4NQFRoBXV6aiKwLRZn/8sRe6MipuOYZXfXI5GnJIEZnuKgsZjGzSBoueTcoWB+
 eUw3MKsktRHhAlH7FIlaknnrt+OnRS8OJaBwSLYNUbOZ+teL2tAqReOoP4k62pgvuI2C
 rXaboWKapR+iOMGgStEpn1mbY1myw0fxiRKgUlGdDk02celrUoAFOGh+9C9rjfAnVu/Z
 HgGEtku14mpo+kLkq2615NS6n+C/NiNF7sKjTaPhbrPLMPC/5LwiN8fEtgUnCMdv8Of9
 mJ+g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=to:date:message-id:subject:mime-version:content-transfer-encoding
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=OGNrG4iZcR6YW3JkxTF1iCj4y7Qu3fNPRjMkHA1d3p0=;
 b=a5ZhRhCCwHOmMCnfu2yXmByjHKP+mMeiUdMkmA2SavEyVxVn173ljkq5M53909fim7
 /pI3lZooJZ9BxxNQEd9lmB1Kyeci+uzRs1ktyeM2N+4JuYRsQROzZa87inCxlg23dPOJ
 UzQsUgEWzfb7SvviO5PeEhJ2RVYW5DE64ExIvHnYx8sm1N+g1vhcAAdiKsdiD3CalelG
 aJzbN1sKpg9/mRtDeEjTyBExS+a4GAGdnWRB8JpTIWydkxfrAuc1LzTh1sDFSeyXwWqG
 KguDzl+5cZjdbIQqfdKHLSeU0IVjZLEcu+LuK6DL42p8zSDDYBodIsI6IYNHunVIaQLh
 yT0A==
X-Gm-Message-State: AFqh2kqciA91Ra7NA0gr2ybCXXnHoqRKBtKfpf+5lc8bshTVEF66XDB6
 qzsRdFLQn3K8+seekyl9atJJxFWohgnPtdnj
X-Google-Smtp-Source: AMrXdXvasBlzK0FDm38lzO7JVWNHuTnFnZEJt0x2OeGFxslWe11vkY8kMQknlEw5H1LoR72/yycxyw==
X-Received: by 2002:ac8:1249:0:b0:3a6:7558:e0af with SMTP id
 g9-20020ac81249000000b003a67558e0afmr66117301qtj.28.1672785064393; 
 Tue, 03 Jan 2023 14:31:04 -0800 (PST)
Received: from smtpclient.apple ([70.107.172.48])
 by smtp.gmail.com with ESMTPSA id
 h25-20020ac87159000000b003a82562c90fsm19245008qtp.62.2023.01.03.14.31.03
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Tue, 03 Jan 2023 14:31:04 -0800 (PST)
From: Sean Devlin <spd@HIDDEN>
Content-Type: text/plain;
	charset=us-ascii
Content-Transfer-Encoding: 7bit
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.300.101.1.2\))
Subject: 28.2; Add tools to find keymaps that bind a given command
Message-Id: <9D2761CB-E158-4D8A-876B-CE1AE0F9ACEA@HIDDEN>
Date: Tue, 3 Jan 2023 17:30:53 -0500
To: bug-gnu-emacs@HIDDEN
X-Mailer: Apple Mail (2.3731.300.101.1.2)
Received-SPF: pass client-ip=2607:f8b0:4864:20::82f;
 envelope-from=spd@HIDDEN; helo=mail-qt1-x82f.google.com
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

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

(Obviously, it depends on what libraries are loaded when the command is
called.)

This is similar to where-is, but it provides a broader view of where the
command is bound. As far as I know, where-is only tells you about
bindings in active maps, and it doesn't tell you which maps contain the
bindings.

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 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.

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.

Thanks!

In GNU Emacs 28.2
System Description:  macOS 13

Configured using:
'configure --with-ns '--enable-locallisppath=/Library/Application
Support/Emacs/${version}/site-lisp:/Library/Application
Support/Emacs/site-lisp' --with-modules'

Configured features:
ACL GMP GNUTLS JSON LIBXML2 MODULES NOTIFY KQUEUE NS PDUMPER THREADS
TOOLKIT_SCROLL_BARS ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/ns-win ns-win ucs-normalize
mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads kqueue cocoa ns multi-tty
make-network-process emacs)

Memory information:
((conses 16 50747 7557)
(symbols 48 6552 1)
(strings 32 18281 2303)
(string-bytes 1 632125)
(vectors 16 13822)
(vector-slots 8 191476 12084)
(floats 8 21 38)
(intervals 56 202 0)
(buffers 992 10))




Acknowledgement sent to Sean Devlin <spd@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#60530; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 4 Sep 2023 15:15:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.