Subject: Re: bug#55393: describe-keymap: suggest symbol at point

From: Visuwesh <[email-masked]>
Date: Fri, 13 May 2022 13:12:26 +0530

[வெள்ளி மே 13, 2022] Eli Zaretskii wrote:

>> From: Visuwesh <[email-masked]>
>> Cc: [email-masked]
>> Date: Fri, 13 May 2022 12:05:42 +0530
>> 
>> > Yes, but I think a cleaner solution would be to do this kind of stuff
>> > in the 'interactive' form of describe-keymap, instead of this
>> > subroutine.  The DWIM-ish operation of describe-SOMETHING commands is
>> > better done there, because it doesn't really belong to non-interactive
>> > invocations.
>> >
>> > Thanks.
>> 
>> The 'interactive' form of describe-keymap uses this function.  I don't
>> see this function being used anywhere else either.
>
> Nothing prevents future reuse of the subroutine in another place.  I
> would prefer to have this code directly in the interactive form, to be
> more future-proof.  And note that the if-let form's result is not used
> in any way in the rest of the code of that function, which also speaks
> volumes of its being an independent issue.

Now done, please check.

>From 596a0f21791cf9d1ffc87e9e142ff81f853c0513 Mon Sep 17 00:00:00 2001
From: Visuwesh <[email-masked]>
Date: Fri, 13 May 2022 13:09:55 +0530
Subject: [PATCH] describe-keymap: Suggest symbol at point

* lisp/help-fns.el (describe-keymap): Suggest symbol at point if it is
a keymap.
* etc/NEWS: Announce the change.
---
 etc/NEWS         | 5 +++++
 lisp/help-fns.el | 5 ++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/etc/NEWS b/etc/NEWS
index e09834c..1cbc9cd 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -562,6 +562,11 @@ minor modes are listed after the major mode.
 The apropos commands will now select the apropos window if
 'help-window-select' is non-nil.
 
+---
+*** 'describe-keymap' now considers the symbol at point.
+'describe-keymap' suggests the symbol at point as the default
+candidate if it is a keymap.
+
 ** Outline Mode
 
 +++
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 927a4f0..807498f 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -1904,7 +1904,10 @@ in `describe-keymap'.  See also `Searching the Active Keymaps'."
 When called interactively, prompt for a variable that has a
 keymap value."
   (interactive
-   (let* ((km (help-fns--most-relevant-active-keymap))
+   (let* ((sym (symbol-at-point))
+          (km (or (and (keymapp (ignore-errors (symbol-value sym)))
+                       sym)
+                  (help-fns--most-relevant-active-keymap)))
           (val (completing-read
                 (format-prompt "Keymap" km)
                 obarray
-- 
2.33.1