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

From: martin rudalics <[email-masked]>
Date: Mon, 25 Nov 2024 10:18:34 +0100

> The key word is "automagically".  Only this is a problem.
 > Many users might not want such magic.
[...]
 > But the category should be the same to match:
 >
 >    (add-to-list 'display-buffer-alist
 >                 '((category . Info-mode)
 >                   (display-buffer-same-window)))
 >
 >    (display-buffer (get-buffer-create "*info*")
 >                    '(nil (category . Info-mode)))
 >
 > So for a similar function like 'display-buffer-reuse-category-window'
 > we need another alist element, not 'category'.
 > Maybe 'display-buffer-reuse-group-window' with 'group' list element
 > for a group of buffers in the same window.

We can't reasonably expect packages to set up yet another alist entry
type like 'group'.  package writers just would not understand it.  So it
simply _has_ to be 'category' (or something else but still only one
thing).

Hence any magic users might not want would have to be implemented within
'display-buffer'.  If say 'run-scheme' wants the same window, then we
already have a problem since a *scheme* window might already exist from
a previous run and it should try 'display-buffer-reuse-window' first.
But this is something for people setting up the default.

Now if no 'inhibit-same-window' alist entry is found and the selected
window is not dedicated to another buffer, 'display-buffer' would use
the selected window as requested.  No automagic here.  Otherwise, it
would look for a window with a 'category' window parameter equaling
'comint' which could, let's assume the worst, mean to use an existing
*shell* window with a running process the user might be attentively
following at that moment.  But the same could happen with your proposal
as well.  So any automagic here should not harm either.

The automagic would come into play when neither caller nor user specify
a particular preference for a window or all other preferences have been
exhausted and 'display-buffer' invokes 'display-buffer-use-some-window'
(not 'display-buffer-reuse-window') in which case that function would
look for a window with a matching 'category' parameter.  Which problems
do you see here?

martin