Does with-selected-window set current buffer?

I am trying to understand if with-selected-window sets current buffer to
the selected window.

with-selected-window calls select-window. The doc string for
select-window makes me a bit confused. At the end of it is a notion that
the command loop selects the buffer of selected window.

Does that mean that select-window does not select that window? Or what
is the comment about?

The reason I am asking is that I have recently seen some cases where I
use with-selected-window in a timer and it looks to me like the code has
been carried out in the wrong buffer. I am not sure yet what is
happening though.

Francis Litterio | 5 Sep 22:35

Re: Does with-selected-window set current buffer?

Lennart Borgman (gmail) wrote:

> I am trying to understand if with-selected-window sets current buffer to
> the selected window.

Well, the current buffer can't be a window object.  I think you meant to
ask if with-selected-window sets the current buffer to the buffer
displayed in the specified window.  As far as I can tell, it does.
--
Fran

Stefan Monnier | 5 Sep 23:49
Gravatar

Re: Does with-selected-window set current buffer?

> I am trying to understand if with-selected-window sets current buffer to
> the selected window.

Not always.  Sadly, it does it in most cases, so it's easy to be mislead
into thinking that it does.

        Stefan

Re: Does with-selected-window set current buffer?

Stefan Monnier wrote:
>> I am trying to understand if with-selected-window sets current buffer to
>> the selected window.
> 
> Not always.  Sadly, it does it in most cases, so it's easy to be mislead
> into thinking that it does.

Thanks. Then it would be very good if the doc string reflected this.


Gmane