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

From: martin rudalics <[email-masked]>
Date: Fri, 22 Nov 2024 10:22:05 +0100

>> I think that the most important improvement of "category" should be to
 >> override "lru".
 >
 > The customization capability, you mean? Nice to have indeed.

What I meant was the following: Calling 'get-lru-window' in
'display-buffer-use-some-window' is a heritage from the times when
'display-buffer' was implemented in C.  It was hard-coded there and
could not be customized.  And it conceptually made sense with multiple
windows because the lru window should be the one whose contents a user
could most likely dispense with.  And it can even work when multiple
'display-buffer' calls are invoked in one and the same command.

The idea misfires in one case: When a user wants one and the same window
display several buffers in sequence.  These buffers could represent
images resulting from browsing an image directory or files containing
grep or xref hits or sources of compile errors.  Anything a user might
want to browse sequentially or, with other words, things a user might
not want to look at at the same time.

In these cases, the lru window will change continuously when multiple
windows are present.  Now if these related buffers were made subject of
a common category and that category were passed as argument to
'display-buffer-use-some-window', the latter could decide - if a window
showing a buffer belonging to the same category existed already - to use
that window instead of the lru one.

Obviously, someone has to decide on setting up the name of the category.
This is the task of the caller of 'display-buffer' - 'image', 'xref',
'grep', 'compile', 'comint' or 'tex' - and would have to be done in a
coordinated fashion so the same category is used twice iff that's really
intended.

In either case, 'display-buffer' would look whether an appropriate
window exists and use that window, maybe also ignoring certain aspects
(dedicatedness, minimum size) that would otherwise prevent its use.

An orthogonal issue is whether an initial command expresses the desire
to show the buffer in "another" window or on "another" frame.  My
suggestion would be to have these suppress any 'category' argument and
have 'display-buffer' proceed as usual, that is use the lru window on
the specified frame , pop up a new frame ...

martin