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

From: [email-masked] (João Távora)
Date: Wed, 25 Oct 2017 16:27:13 +0100

Eli Zaretskii <[email-masked]> writes:

> I understand that the motivation for changing the existing solution
> for the "disappearing XREF buffer" was the unexpected or even
> incorrect behavior when the "C-x 4" variety of the commands is
> invoked.  That is, the existing code would display the definition in
> the original window, not in "the other" window (which is taken by the
> XREF buffer).  And the original solution was to display the definition
> in the window where the XREF buffer was displayed, thus making it
> "disappear".  Is that correct?

More or less. You are 90% correct. I wouldn’t link unexpected behaviour
with the "disappear XREF buffer" because they can be seen as independent
issues, though closely related. Anyway, it’s OK because the fix you
propose further below is exactly the current one I propose (minus some
subtleties for when we "can’t" pop a new window because of insuficient
window dimensions).

> If so, then the easiest solution IMO would be to pop up one more
> window, i.e. behave as if the window displaying the XREF buffer didn't
> exist.  That would both keep the contract of "C-x 4" and leave the
> XREF buffer visible.

Yes, this is the default behaviour in the current patches.

> As for quitting the XREF buffer when it's no longer needed: how about
> 'q', like other similar modes do, or some variety thereof?  "C-u RET"
> is too odd, almost outlandish in Emacs.

’q’ is already taken by ’quit-window’ in *xref* buffers. It quits the
window and does nothing else. I’m looking for a command that quits *and*
goes to the target. If done in this order, it has the nice benefit that
the window thus immediately released is available for showing the cross
reference (in the C-x 4 case, that is)

If no suitable key for this command can be found (’a’, ’o’ would perhaps
be nice), then let’s make an unbound command that I can bound to RET.

Then let’s open a separate discussion on whether that behaviour should
become the default (I think it should).

> If the above solves the remaining issues, and if you have no other
> problems, can we have patches to that effect?

Sure, as soon as you (or we) decide on one of the following:

* C-u RET (for completeness sake, you seem to be against this one)
* ’a’ bound to a new command xref-quit-and-goto-xref
* ’o’ bound to a new command xref-quit-and-goto-xref
* a new unbound command xref-quit-and-goto-xref

> And then the next question would be: what branch to install this on?

It’s a bugfix, so emacs-26.