From 7098a09b3d1d53e2a0c50f57d92fc397a65b4e39 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Thu, 25 Nov 2021 22:37:37 +0000 Subject: [PATCH] Do not buttonize key bindings outside of *Help* buffers * lisp/help.el (substitute-command-keys--in-help): New variable to differentiate calls to substitute-command-keys in *Help* buffers from other calls. (substitute-command-keys): Use the new variable: help-link-key-to-documentation is supposed to have an effect only "in *Help* buffers". Fixes bug#52053. (describe-key): Use the new variable. * lisp/help-fns.el (describe-function, describe-variable, describe-symbol): Use the new variable. * lisp/help-macro.el (make-help-screen): Use the new variable. --- lisp/help-fns.el | 9 ++++++--- lisp/help-macro.el | 3 ++- lisp/help.el | 7 ++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 17fabe4f63..a018cc293b 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -249,7 +249,8 @@ describe-function ;; calling that. (let ((describe-function-orig-buffer (or describe-function-orig-buffer - (current-buffer)))) + (current-buffer))) + (substitute-command-keys--in-help t)) (help-setup-xref (list (lambda (function buffer) @@ -1085,7 +1086,8 @@ describe-variable (user-error "You didn't specify a variable") (save-excursion (let ((valvoid (not (with-current-buffer buffer (boundp variable)))) - val val-start-pos locus) + val val-start-pos locus + (substitute-command-keys--in-help t)) ;; Extract the value before setting up the output buffer, ;; in case `buffer' *is* the output buffer. (unless valvoid @@ -1619,7 +1621,8 @@ describe-symbol (cons name (funcall descfn symbol buffer frame)))) describe-symbol-backends)))) - (single (null (cdr docs)))) + (single (null (cdr docs))) + (substitute-command-keys--in-help t)) (while (cdr docs) (goto-char (point-min)) (let ((inhibit-read-only t) diff --git a/lisp/help-macro.el b/lisp/help-macro.el index 588efee66b..25f6b3ba46 100644 --- a/lisp/help-macro.el +++ b/lisp/help-macro.el @@ -93,7 +93,8 @@ make-help-screen "Help command." (interactive) (let ((line-prompt - (substitute-command-keys ,help-line))) + (substitute-command-keys ,help-line)) + (substitute-command-keys--in-help t)) (when three-step-help (message "%s" line-prompt)) (let* ((help-screen ,help-text) diff --git a/lisp/help.el b/lisp/help.el index 9122d96271..d527f48020 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -929,7 +929,8 @@ describe-key seq (event-start event)))) `(,seq ,brief-desc ,defn ,locus))) key-list)) - 2))) + 2)) + (substitute-command-keys--in-help t)) (help-setup-xref (list (lambda (key-list buf) (describe-key key-list (if (buffer-live-p buf) buf))) @@ -1072,6 +1073,9 @@ help-link-key-to-documentation :version "29.1" :group 'help) +(defvar substitute-command-keys--in-help nil + "Internal variable used by `substitute-command-keys'.") + (defun substitute-command-keys (string) "Substitute key descriptions for command names in STRING. Each substring of the form \\\\=[COMMAND] is replaced by either a @@ -1181,6 +1185,7 @@ substitute-command-keys (delete-char (- end-point (point))) (let ((key (help--key-description-fontified key))) (insert (if (and help-link-key-to-documentation + substitute-command-keys--in-help (functionp fun)) ;; The `fboundp' fixes bootstrap. (if (fboundp 'help-mode--add-function-link) -- 2.33.0