Subject: Re: bug#67993: Selecting buffer automatically

From: Juri Linkov <[email-masked]>
Date: Sat, 06 Jan 2024 19:40:02 +0200

>> Martin, do you agree with this change?
>> If ok, then I could update the documentation as well.
>
> The following looks like a glitch:
>
>>> +                      (when (window-live-p (old-selected-window))
>>> +                        (select-window (old-selected-window))))
>
> is supposed to select the window selected the last time we ran window
> change functions.  Now consider the following scenario:
>
> - Redisplay runs the window change functions and sets the old selected
>   window.
>
> - An application changes the selected window.
>
> - 'display-buffer' gets called with a (select-window . nil) entry.  The
>   call will select the window selected at last redisplay.
>
> So I think that calling 'old-selected-window' here is not TRT.

Could you suggest an alternative to 'old-selected-window'
to select the original window that was selected before
the current command?