Subject: Re: bug#74361: [PATCH] New option xref-navigation-display-window-action

From: martin rudalics <[email-masked]>
Date: Sun, 8 Dec 2024 17:55:39 +0100

>> 'display-buffer' per se doesn't care about the current buffer.  The
 >> assumption that the selected window also holds the current buffer is
 >> nowhere guaranteed.  Just think of 'display-buffer' running from a
 >> timer.
 >
 > I meant the buffer that was current at the beginning of the command:
 > (window-buffer (old-selected-window)).

The doc-string of 'old-selected-window' says

   The return value is the window selected the last time window change
   functions were run.

One and the same command may encompass an arbitrary number of redisplays
(think of a command reading the minibuffer) which all may affect the
return value of that function.  So there is no guarantee that
'old-selected-window' will get you what you expect.

martin