Subject: bug#16816: 24.3.50; erroneous docstring in with-temp-buffer-window

From: martin rudalics <[email-masked]>
Date: Thu, 27 Feb 2014 19:44:55 +0100

> This breaks with-help-window. Try
 >
 >  emacs -Q
 >  C-x C-h
 >
 > the help output is inserted in the current buffer (*scratch*, in this case).

Yes.  A lousy bug.  I introduced it last year relying on the misfeature
that `with-temp-buffer-window' makes the help buffer current.  Does the
following patch fix it?

=== modified file 'lisp/help.el'
--- lisp/help.el	2014-02-10 01:34:22 +0000
+++ lisp/help.el	2014-02-27 18:31:30 +0000
@@ -498,7 +498,8 @@
  then we display only bindings that start with that prefix."
    (let ((buf (current-buffer)))
      (with-help-window (help-buffer)
-      (describe-buffer-bindings buf prefix menus))))
+      (with-current-buffer (help-buffer)
+	(describe-buffer-bindings buf prefix menus)))))

  (defun where-is (definition &optional insert)
    "Print message listing key sequences that invoke the command DEFINITION.

 > This patch fixes it.
 >
 > === modified file 'lisp/help.el'
 > --- lisp/help.el 2014-02-10 01:34:22 +0000
 > +++ lisp/help.el 2014-02-27 15:29:05 +0000
 > @@ -1207,7 +1207,8 @@
 >     (temp-buffer-window-show-hook
 >      (cons 'help-mode-finish temp-buffer-window-show-hook)))
 >         (with-temp-buffer-window
 > - ,buffer-name nil 'help-window-setup (progn ,@body)))))
 > + ,buffer-name nil 'help-window-setup
 > + (with-current-buffer ,buffer-name ,@body)))))
 >
 >  ;; Called from C, on encountering `help-char' when reading a char.
 >  ;; Don't print to *Help*; that would clobber Help history.
 >

This would restore what we had till now: BODY would get evaluated in the
help buffer and not in the original buffer.  I doubt this could have any
serious consequences (Emacs 24.3 runs this already for quite some time)
but it's inherently disturbing.

martin