help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: (save-excursion (other-window 1)) leaves me in the other window


From: David Kastrup
Subject: Re: (save-excursion (other-window 1)) leaves me in the other window
Date: Tue, 04 May 2010 15:41:55 -0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.92 (gnu/linux)

Sean McAfee <smcafee@palantirtech.com> writes:

> Sean McAfee <eefacm@gmail.com> writes:
>> If the current buffer is restored, then I would expect this expression:
>>
>> (eq (current-buffer) (save-excursion arbitrary-forms (current-buffer)))
>>
>> ...to always evaluate to t regardless of what arbitrary-forms is, but it
>> returns nil if I replace arbitrary-forms with (other-window 1).
>
> Argh.  Of course the expression I meant to write was:
>
> (eq (current-buffer) (progn (save-excursion arbitrary-forms) 
> (current-buffer)))
>
> This actually does return t in the presence of multiple windows even if
> arbitrary-forms is (other-window 1), and yet the cursor still ends up in
> a different window than the one it was in before evaluating the
> expression.  I still don't get it.  I guess maybe other-window doesn't
> switch windows immediately, but defers the switch until after the
> expression has been fully evaluated?

other-window changes the current window, not the current buffer.  When
Emacs returns to the command loop, the current buffer is set to the
window-buffer of the current window.

-- 
David Kastrup


reply via email to

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