Subject: Re: bug#17007: 24.3.50; describe-key/function evaluates documentation function in the wrong buffer

From: [email-masked] (João Távora)
Date: Fri, 14 Mar 2014 12:08:08 +0000

martin rudalics <[email-masked]> writes:

> Sorry, I messed this up too often already.  Hopefully, it's sufficient
> to add one `with-current-buffer' binding at some particular level.
> Could you please send me the calling sequence used by yasnippet, so I
> can identify the location where this is necessary?

It's simpler if I give you an emacs -Q recipe, right? In your *scratch*
buffer:

    (defun foo ())
    (defun foo-doc ()
      (format "Foo does nothing, and by the way your tab does `%s'"
            	     (key-binding "\t")))
    (put 'foo 'function-documentation '(foo-doc))
    (describe-function 'foo)

This fails on the latest Emacs, i.e. the last line returned by the last
form is

    "Foo does nothing, and by the way your tab does `forward-button'"

Whereas it should report, as in Emacs 24.3

    "Foo does nothing, and by the way your tab does `indent-for-tab-command'"

The trace of functions is the following:

1 -> (describe-function foo)
| 2 -> (describe-function-1 foo)
| | 3 -> (documentation foo t)
| | 3 <- documentation: "Foo does nothing, and by the way your tab does `forward-button'"
| 2 <- describe-function-1: nil
1 <- describe-function: "foo is a Lisp function.

But that doesn't show how the macro `with-temp-buffer-window', expanded
from `with-help-window', eventually wraps the latter's BODY in a
`with-current-buffer' call, making its forms be evaluated in the newly
created *Help* buffer, instead of *scratch*. One of those forms is the
call to `describe-function-1', which eventually calls `foo-doc'.

As I explained in my last email (which got sent from the wrong address
but is here
http://lists.gnu.org/archive/html/bug-gnu-emacs/2014-03/msg00411.html)
it was the reversion of two lines in `with-temp-buffer-window' that
broke it.

But maybe it was fixing something else that I don't understand. Can you
help me understand what you were achieving with the original fix and the
reversion?
    
João