On 6/27/05, Juri Linkov <[EMAIL PROTECTED]> wrote:
>   (with-current-buffer "c"
>     (pop-to-buffer "b"))
>   (message "%s" (buffer-name (current-buffer))))
> 
> At the end, it print "a" as the current buffer name, but actually
> this command makes the buffer "b" current.  Shouldn't it print "b"?

I think this isn't a bug -- the `with-current-buffer' form of course
restores the current buffer to be "a" after the wrapped code is
finished; why would you expect differently?

As I understand it, what `pop-to-buffer' does is set the window-buffer
of the selected window, in _addition_ to setting the current buffer,
and the main emacs interaction loop always restores the current buffer
to be the window-buffer of the selected window when you look for the
next command.

So in your example, `pop-to-buffer' sets the current buffer and the
window-buffer-of-selected-widnow to be "b", then the
`with-current-buffer' form (correctly) restores the current buffer to
be "a" again, then you print your message [which says "current buffer
is a"], then the interaction loop goes to read a command, which sets
the current buffer based on the window state -- which is "b", because
of pop-to-buffer's effect.

-Miles
-- 
Do not taunt Happy Fun Ball.


_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

Reply via email to