From: martin rudalics via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Juri Linkov <juri@linkov.net>
Cc: Morgan Smith <Morgan.J.Smith@outlook.com>,
Eli Zaretskii <eliz@gnu.org>,
74246@debbugs.gnu.org, stefankangas@gmail.com
Subject: bug#74246: [PATCH] Reuse display windows in image-dired
Date: Fri, 6 Dec 2024 09:33:33 +0100 [thread overview]
Message-ID: <6689d418-d028-40b8-b3d2-4ff12fe4283a@gmx.at> (raw)
In-Reply-To: <87cyi6f2gb.fsf@mail.linkov.net>
>> The second specification has the drawback that _any_ 'display-buffer'
>> call that relies on 'display-buffer-use-some-window' may use that
>> window. Just think of an error occurring during that call: The
>> *backtrace* buffer will pop up in the window specified by that variable
>> although it is by no means related to it.
>
> Indeed, this is not good. So only a category can ensure that
> the same display-buffer call is used?
You mean that is uses the same window? There cannot be such a
guarantee. That window might have been (de-)selected, (temporarily)
deleted, made dedicated and for any such reason may have become
unsuitable for 'display-buffer'. In the course of years people have
added more and more conditions why 'display-buffer' should avoid certain
windows. Think of 'display-buffer-avoid-small-windows' - a global
option that completely sidesteps the internal alist concept.
> It's fine to set a buffer-local variable in the buffer where the user
> types a key that displays the target buffer from another source buffer.
> As long as the same buffer is used to get the value of this variable.
I have no idea of a secure way to retrieve that buffer.
> There are two goals:
>
> 1. replace the current lru with another default that reuses a previous window.
> But not complicating all exiting display-buffer calls by requiring
> each of them to set a buffer-local variable. When a standard variable
> will be set, then it can be shared by different calls.
Whatever we do: The buffer-local variable would have to be an option to
fix the existing misbehavior of lru. And it should be used only in
cases where 'display-buffer-reuse-window' can't find a suitable windows.
'image-dired' could safely use 'display-buffer-reuse-window' because it
eventually displays its images always in the same buffer. It cannot do
that right away in its present version because that one does ...
(let ((buf (get-buffer image-dired-display-image-buffer))
(cur-win (selected-window)))
(when buf
(kill-buffer buf))
(when-let ((buf (find-file-noselect file nil t)))
(pop-to-buffer buf)
... first pop up a buffer showing 'file' which means that
'display-buffer-reuse-window' usually won't find such a window ...
(rename-buffer image-dired-display-image-buffer)
... and then renames that buffer to 'image-dired-display-image-buffer' -
a buffer that 'display-buffer-reuse-window' would have found if it has
been displayed at least once. Note that the present lru mischief
doesn't happen for the first image displayed. It happens for successive
image displays only, where 'image-dired-display-image-buffer' has been
already displayed at least once.
And note the 'kill-buffer' killing 'image-dired-display-image-buffer'.
That one defies any attempt to set a buffer-local variable in that
buffer.
> 2. make user customization easy by using a special symbol like
> '(some-window . reuse). But directly using the variable
> is also fine, e.g. `(some-window . ,last-window)
I would have to understand the semantics of 'reuse' first. What
'display-buffer' cannot handle currently is something like the
'image-dired' scenario above where the buffer would not be renamed. In
that case it would be nice if the caller could set a 'category' or a
'some-window' alist entry and 'display-buffer' could use that to find a
window with the same 'category' or 'some-window' value and display the
buffer there.
martin
next prev parent reply other threads:[~2024-12-06 8:33 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 20:19 bug#74246: [PATCH] Reuse display windows in image-dired Morgan Smith
2024-11-09 11:37 ` Eli Zaretskii
2024-11-09 17:36 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-23 12:16 ` Eli Zaretskii
2024-11-28 0:32 ` Morgan Smith
2024-11-28 9:28 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-28 18:27 ` Juri Linkov
2024-11-29 15:53 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-30 18:03 ` Juri Linkov
2024-12-01 8:46 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-02 7:42 ` Juri Linkov
2024-12-02 11:22 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-03 7:47 ` Juri Linkov
2024-12-03 8:25 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-03 17:24 ` Juri Linkov
2024-12-04 7:59 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-04 17:18 ` Juri Linkov
2024-12-05 9:23 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-05 17:54 ` Juri Linkov
2024-12-06 8:33 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-12-07 17:13 ` Juri Linkov
2024-12-08 16:55 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-09 19:16 ` Juri Linkov
2024-12-10 15:55 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-10 17:30 ` Juri Linkov
2024-12-11 9:38 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-12 7:52 ` Juri Linkov
2024-12-12 9:23 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-12 16:40 ` Juri Linkov
2024-12-12 17:24 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-12 18:42 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6689d418-d028-40b8-b3d2-4ff12fe4283a@gmx.at \
--to=bug-gnu-emacs@gnu.org \
--cc=74246@debbugs.gnu.org \
--cc=Morgan.J.Smith@outlook.com \
--cc=eliz@gnu.org \
--cc=juri@linkov.net \
--cc=rudalics@gmx.at \
--cc=stefankangas@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).