]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix to help-buffer to ensure it returns a valid buffer (Bug#8147).
authorChong Yidong <cyd@stupidchicken.com>
Sat, 5 Mar 2011 21:10:03 +0000 (16:10 -0500)
committerChong Yidong <cyd@stupidchicken.com>
Sat, 5 Mar 2011 21:10:03 +0000 (16:10 -0500)
* lisp/help-mode.el (help-buffer): If we are to return the current
buffer, signal an error if it's not in Help mode.

lisp/ChangeLog
lisp/help-mode.el

index 707464670e9fd9204973e20a645af374117913b9..55935189af6570dfb688ae88c8044244af5453a4 100644 (file)
@@ -1,3 +1,8 @@
+2011-03-05  Chong Yidong  <cyd@stupidchicken.com>
+
+       * help-mode.el (help-buffer): If we are to return the current
+       buffer, signal an error if it's not in Help mode (Bug#8147).
+
 2011-03-05  Reuben Thomas  <rrt@sc3d.org>
 
        * files.el (file-name-version-regexp): Handle backup files of the
index 724b0186679350c4c4649418885b5351881bea2d..51d18235e1bed74362acdb490a67d8f025191cf9 100644 (file)
@@ -409,13 +409,16 @@ restore it properly when going back."
 (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.
-Otherwise, it is *Help*; if no buffer with that name currently
-exists, it is created."
+current buffer.  Signal an error if this buffer is not derived
+from `help-mode'.
+Otherwise, return \"*Help*\", creating a buffer with that name if
+it does not already exist."
   (buffer-name                         ;for with-output-to-temp-buffer
-   (if help-xref-following
-       (current-buffer)
-     (get-buffer-create "*Help*"))))
+   (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))))
 
 (defvar help-xref-override-view-map
   (let ((map (make-sparse-keymap)))