unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#61505: [PATCH] Handle anonymous commands in C-h K
@ 2023-02-14  7:39 Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-01-10 22:51 ` Stefan Kangas
  0 siblings, 1 reply; 2+ messages in thread
From: Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-02-14  7:39 UTC (permalink / raw)
  To: 61505

[-- Attachment #1: Type: text/plain, Size: 1080 bytes --]

Tags: patch

Currently C-h K (Info-goto-emacs-key-command-node) throws an error when
used on anonymous commands, for example:

1. emacs -Q
2. Evaluate this form:
    (keymap-global-set "C-c m"
                       (lambda ()
                         (interactive)
                         (message "foo")))
3. Type C-h K C-c m
4. Get this error:
    Info-goto-emacs-command-node: Wrong type argument: symbolp, (closure (t) nil (interactive) (message "foo"))

This patch makes Info-goto-emacs-key-command-node detect and handle such
cases by printing an informative message instead of calling
Info-goto-emacs-command-node.


In GNU Emacs 30.0.50 (build 6, x86_64-apple-darwin22.2.0, NS
 appkit-2299.30 Version 13.1 (Build 22C65)) of 2023-02-11 built on
 esmac.lan
Repository revision: 838415525bd4e77a79e18af8e4f01ed004196c71
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2299
System Description:  macOS 13.1

Configured using:
 'configure --with-native-compilation --with-json --with-xwidgets
 --with-mailutils --with-imagemagick --without-dbus'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Handle-anonymous-commands-in-C-h-K.patch --]
[-- Type: text/patch, Size: 1015 bytes --]

From b835e3ab3803ba0344a068dd00b2fc413c3cc970 Mon Sep 17 00:00:00 2001
From: Eshel Yaron <me@eshelyaron.com>
Date: Tue, 14 Feb 2023 09:18:37 +0200
Subject: [PATCH] Handle anonymous commands in C-h K

* lisp/info.el (Info-goto-emacs-key-command-node): Don't call
Info-goto-emacs-command-node for anonymous commands.
---
 lisp/info.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/info.el b/lisp/info.el
index 035dff66e75..cf11b782bef 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -4671,8 +4671,11 @@ Info-goto-emacs-key-command-node
 		(eq command 'execute-extended-command))
 	   (Info-goto-emacs-command-node
 	    (read-command "Find documentation for command: ")))
+          ((symbolp command)
+           (Info-goto-emacs-command-node command))
 	  (t
-	   (Info-goto-emacs-command-node command)))))
+	   (message "%s invokes an anonymous command"
+                    (key-description key))))))
 \f
 (defvar Info-link-keymap
   (let ((keymap (make-sparse-keymap)))
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#61505: [PATCH] Handle anonymous commands in C-h K
  2023-02-14  7:39 bug#61505: [PATCH] Handle anonymous commands in C-h K Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-01-10 22:51 ` Stefan Kangas
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Kangas @ 2024-01-10 22:51 UTC (permalink / raw)
  To: Eshel Yaron; +Cc: 61505-done

Version: 30.1

Eshel Yaron <me@eshelyaron.com> writes:

> Currently C-h K (Info-goto-emacs-key-command-node) throws an error when
> used on anonymous commands, for example:
>
> 1. emacs -Q
> 2. Evaluate this form:
>     (keymap-global-set "C-c m"
>                        (lambda ()
>                          (interactive)
>                          (message "foo")))
> 3. Type C-h K C-c m
> 4. Get this error:
>     Info-goto-emacs-command-node: Wrong type argument: symbolp, (closure (t) nil (interactive) (message "foo"))
>
> This patch makes Info-goto-emacs-key-command-node detect and handle such
> cases by printing an informative message instead of calling
> Info-goto-emacs-command-node.

Thanks, makes sense to me, so I installed it on master (9eed00c8e5a).

I changed the message to be slightly more clear in a followup commit to
look like this:

    C-c m invokes an anonymous command defined with ‘lambda’

I also made it use `substitute-command-keys'.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-10 22:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-14  7:39 bug#61505: [PATCH] Handle anonymous commands in C-h K Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-10 22:51 ` Stefan Kangas

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).