emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master dc9337aacd: Allow using xref buttons in non-*Help* buffers


From: Lars Ingebrigtsen
Subject: master dc9337aacd: Allow using xref buttons in non-*Help* buffers
Date: Mon, 6 Jun 2022 10:12:45 -0400 (EDT)

branch: master
commit dc9337aacd682b6346b7918ec9b3067e3a06269b
Author: Stephen Berman <stephen.berman@gmx.net>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Allow using xref buttons in non-*Help* buffers
    
    * lisp/help-mode.el (help-buffer): Allow using the xref buttons in
    non-*Help* buffers (bug#8147) (but display the result in a *Help*
    buffer).
---
 lisp/help-mode.el            | 17 ++++++++---------
 test/lisp/help-mode-tests.el |  5 -----
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index 2fcb8b9f3e..a50524253b 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -515,17 +515,16 @@ restore it properly when going back."
 ;;;###autoload
 (defun help-buffer ()
   "Return the name of a buffer for inserting help.
-If `help-xref-following' is non-nil, this is the name of the
-current buffer.  Signal an error if this buffer is not derived
-from `help-mode'.
+If `help-xref-following' is non-nil and the current buffer is
+derived from `help-mode', this is the name of the current buffer.
+
 Otherwise, return \"*Help*\", creating a buffer with that name if
 it does not already exist."
-  (buffer-name                         ;for with-output-to-temp-buffer
-   (if (not help-xref-following)
-       (get-buffer-create "*Help*")
-     (unless (derived-mode-p 'help-mode)
-       (error "Current buffer is not in Help mode"))
-     (current-buffer))))
+  (buffer-name                         ;for with-output-to-temp-buffer
+   (if (and help-xref-following
+            (derived-mode-p 'help-mode))
+       (current-buffer)
+     (get-buffer-create "*Help*"))))
 
 (defvar describe-symbol-backends
   `((nil ,#'fboundp ,(lambda (s _b _f) (describe-function s)))
diff --git a/test/lisp/help-mode-tests.el b/test/lisp/help-mode-tests.el
index b5bdf6b8d4..04241f3138 100644
--- a/test/lisp/help-mode-tests.el
+++ b/test/lisp/help-mode-tests.el
@@ -41,11 +41,6 @@
       (should (equal (buffer-name (current-buffer))
                      (help-buffer))))))
 
-(ert-deftest help-mode-tests-help-buffer-current-buffer-error ()
-  (with-temp-buffer
-    (let ((help-xref-following t))
-      (should-error (help-buffer)))))
-
 (ert-deftest help-mode-tests-make-xrefs ()
   (with-temp-buffer
     (insert "car is a built-in function in ‘C source code’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]