From f0e44fc134ada890473769e80770e70e64ab11a1 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Thu, 25 Nov 2021 10:19:32 +0000 Subject: [PATCH] Do not buttonize key bindings outside of *Help* buffers * lisp/help.el (substitute-command-keys): help-link-key-to-documentation is supposed to have an effect only "in *Help* buffers". Detect whether the output will go in a *Help* buffer, and if not, do not buttonize the key binding. Fixes bug#52053. --- lisp/help.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lisp/help.el b/lisp/help.el index bc3d4773da..2e21060d35 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -1105,7 +1105,9 @@ substitute-command-keys ;; itself. (let ((keymap overriding-local-map) (inhibit-modification-hooks t) - (orig-buf (current-buffer))) + (orig-buf (current-buffer)) + (in-help (eq (car temp-buffer-window-setup-hook) + 'help-mode-setup))) (with-temp-buffer (insert string) (goto-char (point-min)) @@ -1161,7 +1163,8 @@ substitute-command-keys (delete-char (- end-point (point))) (let ((key (help--key-description-fontified key))) (insert (if (and help-link-key-to-documentation - (functionp fun)) + (functionp fun) + in-help) ;; The `fboundp' fixes bootstrap. (if (fboundp 'help-mode--add-function-link) (help-mode--add-function-link key fun) -- 2.33.0