Subject: Re: bug#74246: [PATCH] Reuse display windows in image-dired

From: martin rudalics <[email-masked]>
Date: Wed, 11 Dec 2024 10:38:21 +0100

> I still don't understand how a local variable in one target buffer could
 > help to display another buffer in the same window from grep/xref list.

By having grep do the following:

- Issue a first request to display a buffer from that list,

- remember the window used,

- set the local variable in the target buffer to the remembered value
   before calling 'display-buffer' again.

It could do that if it wanted to communicate the window to use in a
buffer local variable thus avoiding to pass an extra value via the
alist.

 >> Would you like that?  I think displaying *backtrace* in the same window
 >> is always a bad idea.
 >
 > Only when 'display-buffer-below-selected' fails that is extremely rare.

I assumed that the user had customized it.

 >>>> pass the symbol of the function calling 'display-buffer' with some
 >>>> unique number identifying the nth call of 'display-buffer' within that
 >>>> function.  Everything else is guesswork.
 >>>
 >>> There is already such a symbol: 'category'.

'category' is much broader.

 >> But this one is already handled by 'buffer-match-p'.  We can't set it
 >> willy-nilly to some arbitrary value.  Otherwise, that function might
 >> match it in an unexpected way.
 >
 > 'display-buffer-reuse-category-window' could reuse the 'category' symbol.
 > Or '(some-window . reuse-category)'.

Let me turn the table and ask you: Both grep/xref know very well which
window was used for displaying the last match.  What speaks again to
have them just remember that window after each call and propose it via a
(some-window . ,window) alist entry in the next call together with
'display-buffer-use-some-window'?  I think the main advantage of such an
approach is that grep/xref would be in complete control of a good
proposal for such a window, something most users could hardly resist.

 > Not either, but preferably the last used window.

Not preferably, IMHO.

 >> 'image-dired' _is_ different because it always uses the same buffer for
 >> showing images stored in different files.  I know of no other function
 >> doing that.  Do you?
 >
 > I don't remember any other function doing such non-standard things.

So IMHO we should exploit that fact in its 'display-buffer' call.

martin