From: Stefan Kangas Date: Sat, 26 Nov 2022 08:37:48 +0000 (+0100) Subject: Use substitute-command-keys in Info-index error X-Git-Tag: emacs-29.0.90~1490 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=30d4011b8a43f29cdda2eeea95cce17fa1435bf1;p=emacs.git Use substitute-command-keys in Info-index error * lisp/info.el (info--ensure-not-in-directory-node): New helper function using substitute-command-keys for error message. (Info-index, Info-virtual-index): Use it. --- diff --git a/lisp/info.el b/lisp/info.el index 8860a664bd7..7d44a1cec1d 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -3329,6 +3329,12 @@ If FILE is nil, check the current Info file." (or node (error "No index")) (Info-goto-node node))) +(defun info--ensure-not-in-directory-node () + (if (equal Info-current-file "dir") + (error (substitute-command-keys + (concat "The Info directory node has no index; " + "type \\[Info-menu] to select a manual"))))) + ;;;###autoload (defun Info-index (topic) "Look up a string TOPIC in the index for this manual and go to that entry. @@ -3342,15 +3348,13 @@ Give an empty topic name to go to the Index node itself." (Info-complete-menu-buffer (clone-buffer)) (Info-complete-nodes (Info-index-nodes)) (Info-history-list nil)) - (if (equal Info-current-file "dir") - (error "The Info directory node has no index; use m to select a manual")) + (info--ensure-not-in-directory-node) (unwind-protect (with-current-buffer Info-complete-menu-buffer (Info-goto-index) (completing-read "Index topic: " #'Info-complete-menu-item)) (kill-buffer Info-complete-menu-buffer))))) - (if (equal Info-current-file "dir") - (error "The Info directory node has no index; use m to select a manual")) + (info--ensure-not-in-directory-node) ;; Strip leading colon in topic; index format does not allow them. (if (and (stringp topic) (> (length topic) 0) @@ -3533,8 +3537,7 @@ search results." (Info-complete-menu-buffer (clone-buffer)) (Info-complete-nodes (Info-index-nodes)) (Info-history-list nil)) - (if (equal Info-current-file "dir") - (error "The Info directory node has no index; use m to select a manual")) + (info--ensure-not-in-directory-node) (unwind-protect (with-current-buffer Info-complete-menu-buffer (Info-goto-index)