Subject: bug#28814: [BUMP, PATCH] (26.0.90; When *xref* window is needed, original window-switching intent is lost )

From: Dmitry Gutov <[email-masked]>
Date: Mon, 23 Oct 2017 05:06:37 +0300

Hi Joao,

On 10/20/17 12:13 PM, João Távora wrote:
> Hoping someone can take a look at this bug I reported a week ago.  Here
> are two very simple Emacs -Q recipes that demonstrate it.

You are working on something that I agree is a real problem, but doing 
this would effectively revert commit 
5698947ff9335cf150c73cca257a5e7e5951b045, which was based on a previous 
discussion (see the link in the commit message), and in particular, 
would bring back "disappearing *xref* buffer problem", as Eli put it.

The essence of the problem is that xref buffers try to serve two related 
but distinct purposes that the user might be aiming at:

- Pick a result from the list and jump to it, forgetting the rest 
(basically providing a completion interface).
- Iterate through results and do something with each of them in turn.

Even for xref-find-definitions, we can't rule out the purpose #2. Again, 
also see the previous discussion.

I have a rough idea on how to fix the situation, but nothing even close 
to an implementation.

>     emacs -Q
>     C-x 3 [split-window-right]
>     C-x 2 [split-window-below]
>     M-. xref-backend-definitions RET [xref-find-definitions]
>     C-n [next-line]
>     RET [xref-goto-xref]
> 
> Expected the definition to be found in the original window where I
> pressed M-. but instead it was found in another. Another case:
> 
>     emacs -Q
>     C-x 4 . xref-backend-definitions RET [xref-find-definitions-other-window]
>     C-n
>     RET
> 
> Expected the definition to be found in some other window, different from
> the one I pressed M-. on. Instead went to the same one.

With your patches applied, this example pops a new frame for me if I 
press 'n' instead of 'C-n'. This is not hugely important in the light of 
the larger problems above, but demonstrated difficulties with window 
management when we try to pretend that the xref buffer "was never there".

> Also, in both
> situations, expected the window configuration to be the same as if I had
> searched for, say xref-backend-functions.
> 
> This is fixed by the patches that I reattach after minor tweaks. The
> general idea is to have the *xref*, whose sudden appearance is hard to
> predict, obtrude as little as possible on the user's window
> configuration.

If we don't bring back the "disappearing *xref* buffer problem", *xref* 
has to stay obtrusive. Do you think the rest of your patch will make 
sense with that change?