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

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 15 May 2022 05:27:02 +0000

Your bug report

#55393: describe-keymap: suggest symbol at point

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
55393: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=55393
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#55393: describe-keymap: suggest symbol at point
From: Eli Zaretskii <[email-masked]>
To: Visuwesh <[email-masked]>
Cc: [email-masked]
Date: Sun, 15 May 2022 08:26:30 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Visuwesh <[email-masked]>
> Cc: [email-masked]
> Date: Fri, 13 May 2022 18:17:11 +0530
> 
> I changed the text to,
> 
>     *** 'describe-keymap' now considers the symbol at point.
>     If the symbol at point is a keymap, 'describe-keymap' suggests it as
>     the default candidate.

Perfect, thanks.

> > Let's wait for a day or two to let others time to comment on this.
> 
> Sure!

No further comments, so I've now installed this on the master branch.

One nit for the future: please always mention the bug number, when
it's known, in the commit log message.  (I added it for you this
time.)

And with that, I'm closing the bug.  Thanks  for working on this.

Subject: describe-keymap: suggest symbol at point
From: Visuwesh <[email-masked]>
To: [email-masked]
Date: Fri, 13 May 2022 09:35:25 +0530
List-Id: <debbugs-submit.debbugs.gnu.org>

Tags: patch

describe-keymap differs from other describe-* commands in that it does
not suggest the symbol at point which always annoyed me.  This patch
makes describe-keymap consider the symbol at point first.

[ I hope it is okay to use if-let family of macros in these files now?  ]

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

* lisp/help-fns.el (help-fns--most-relevant-active-keymap): Suggest
the symbol at point if it is a keymap.
* etc/NEWS: Announce the change.
---
 etc/NEWS         |  5 +++++
 lisp/help-fns.el | 17 +++++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 273fa77640..251ebc46ce 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -363,6 +363,11 @@ These will take you (respectively) to the next and previous "page".
 This will take you to the Emacs Lisp manual entry for the item
 displayed, if any.
 
+---
+*** '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
 
 *** Support for customizing the default visibility state of headings.
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 80d7d5cb02..3836cc7367 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -1779,16 +1779,21 @@ help-fns--most-relevant-active-keymap
 The heuristic to determine which keymap is most likely to be
 relevant to a user follows this order:
 
-1. 'keymap' text property at point
-2. 'local-map' text property at point
-3. the `current-local-map'
+1. symbol at point
+2. 'keymap' text property at point
+3. 'local-map' text property at point
+4. the `current-local-map'
 
 This is used to set the default value for the interactive prompt
 in `describe-keymap'.  See also `Searching the Active Keymaps'."
-  (help-fns-find-keymap-name (or (get-char-property (point) 'keymap)
-                         (if (get-text-property (point) 'local-map)
+  (if-let ((sym (symbol-at-point))
+           (sym (when sym (intern-soft sym)))
+           (keymapp (ignore-errors (symbol-value sym))))
+      sym
+    (help-fns-find-keymap-name (or (get-char-property (point) 'keymap)
+                           (if (get-text-property (point) 'local-map)
                              (get-char-property (point) 'local-map)
-                           (current-local-map)))))
+                           (current-local-map))))))
 
 (defvar keymap-name-history nil
   "History for input to `describe-keymap'.")
-- 
2.33.1

In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars)
Repository revision: ca3858563c7ba8ee3caa82fbd2b7c386ea60c0d3
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: NixOS 21.11 (Porcupine)

Configured using:
 'configure
 --prefix=/nix/store/iqqk7iqfwmfc6r78xg2knyq7hww2mhs4-emacs-git-20220225.0
 --disable-build-details --with-modules --with-x-toolkit=lucid
 --with-xft --with-cairo --with-native-compilation'