emacs-devel
[Top][All Lists]
Advanced

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

Re: with-current-buffer


From: Kevin Rodgers
Subject: Re: with-current-buffer
Date: Tue, 28 Jun 2005 11:28:48 -0600
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

Juri Linkov wrote:
> What causes trouble here is the fact that Emacs changes the current
> buffer behind the scenes (somewhere in the main loop), so at the end
> of the function it is not known what the buffer will be current after
> the function finishes.  But sometimes it is desirable to perform some
> actions on that buffer (e.g. run hooks).

But you also changed the selected window.  That is the cause of the
trouble.

> Maybe with-current-buffer should keep track of switching buffers
> inside with-current-buffer, so it could anticipate what a buffer will
> be set as current and don't restore the old buffer.
>
> Or maybe `pop-to-buffer inside with-current-buffer' is not a suitable
> programming construct (I mean mostly for the `next-error' command
> where this problem occurred) and it's better to replace it with more
> explicit buffer switching that will restore the old buffer only when
> there were no `pop-to-buffer' calls.

In the old days we'd use save-window-excursion; now there is
save-selected-window.

Should there be a with-selected-window macro, analogous to
with-current-buffer?

--
Kevin Rodgers





reply via email to

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