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

From: martin rudalics <[email-masked]>
Date: Tue, 10 Dec 2024 16:55:32 +0100

> What would be the safest approach to detect the same 'display-buffer' call?
 > A category?

As I already mentioned: The calling function would have to reserve a
separate alist entry for it.  In my initial proposal I had even a
separate argument for that purpose.  Alternatively, one could reserve a
local variable in the target buffer for that purpose ('display-buffer'
would have to reset it).

 >> Unless a user has customized it or 'display-buffer-below-selected' fails
 >> for some reason.
 >
 > Then displaying it by some-window in the same window instead of lru
 > looks as a nice thing to do.

Would you like that?  I think displaying *backtrace* in the same window
is always a bad idea.

 >> As I said above this is not reliable.  The only reliable thing is to
 >> 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'.

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.

 >> If a user issues the command to display an image in a window that
 >> already shows an image and insists on using another window, an arbitrary
 >> other window can be chosen.  Users who want that just get the usual
 >> chaotic behavior lru provides.  They asked for it.
 >
 > The users might want to switch displaying to another window,
 > and continue displaying other images in the same other window.

Yes.  But then either of the windows could be chosen by the next call
(if that window still exists).

 >> With 'image-dired' it can be set in the image buffer because that buffer
 >> is always the same.
 >
 > This is an exception, not a general rule such as for navigating
 > grep/xref results.  I see no reason for image-dired be different
 > from grep/xref.

'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?

martin