From: Juri Linkov <juri@linkov.net>
To: martin rudalics <rudalics@gmx.at>
Cc: 70949@debbugs.gnu.org
Subject: bug#70949: display-buffer-choose-some-window
Date: Fri, 24 May 2024 20:38:34 +0300 [thread overview]
Message-ID: <86zfsfqgtl.fsf@mail.linkov.net> (raw)
In-Reply-To: <f9970431-325e-44b0-b959-ed9839d7ba47@gmx.at> (martin rudalics's message of "Fri, 24 May 2024 11:32:16 +0200")
>> This makes the behavior more predictable: the user will know that all
>> buffers will be displayed in the most recently used window, so the user
>> can switch to that window before continuing to navigate buffers.
>
> Not really. The window switched to becomes the selected window and the
> 'mru' window used will be the window where the user was working before
> the switch due to NOT-SELECTED being t.
I meant switching to the window to instruct display-buffer what window
to use as mru, then switch back to the rgrep window.
>>> Then maybe a separate category for rgrep buffers could help here.
>>
>> This is not about rgrep buffers.
>
> Consider the completely untested action function below supposed to be
> called with a (related-window . rgrep) alist argument.
We already have 'previous-window' that I'm using for a long time,
and it works nicely with such configuration:
(defvar-local display-buffer-previous-window nil)
(defun display-buffer-from-grep-p (_buffer-name _action)
(with-current-buffer (window-buffer)
(and (memq this-command '(compile-goto-error))
(derived-mode-p '(compilation-mode)))))
(add-to-list 'display-buffer-alist
'(display-buffer-from-grep-p
display-buffer-in-previous-window
(previous-window . display-buffer-previous-window)
(inhibit-same-window . nil))
;; Append to not override display-buffer-same-window
'append)
(define-advice compile-goto-error (:around (ofun &rest args) previous-window)
(let ((buffer (current-buffer)))
(apply ofun args)
(with-current-buffer buffer
(setq-local display-buffer-previous-window (selected-window)))))
But this is very complicated configuration. So I wanted to help people
to do basically the same with much simpler setting that overrides
the hard-coded 'lru' with just '(some-window . mru)'.
The only problem with '(some-window . mru)' is that its NOT-SELECTED is t,
so this excludes the very useful case of displaying the buffer
in the same selected window. For example, with 'previous-window'
I often visit rgrep results in the same window where the rgrep buffer
was displayed. This keeps everything confined to one window.
I see that in your display-buffer-in-related-window
'related-window' is a window parameter. I think this is
much better than a buffer-local variable that I used above.
But a new alist 'related-window' should also update
the 'related-window' window parameter in 'post-command-hook'
like 'post-command-select-window' does.
Then the customization for users would be very simple:
(add-to-list 'display-buffer-alist
'((category . rgrep) (display-buffer-in-related-window)))
Or maybe a better name would be 'display-buffer-in-last-window'?
In any case this looks like a workable solution
that will create a connection between windows.
next prev parent reply other threads:[~2024-05-24 17:38 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-14 16:56 bug#70949: display-buffer-choose-some-window Juri Linkov
2024-05-15 8:06 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-15 16:49 ` Juri Linkov
2024-05-16 8:20 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-17 6:40 ` Juri Linkov
2024-05-18 9:21 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-20 6:15 ` Juri Linkov
2024-05-20 8:01 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-20 16:54 ` Juri Linkov
2024-05-21 8:21 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-21 17:18 ` Juri Linkov
2024-05-22 7:39 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-23 6:16 ` Juri Linkov
2024-05-23 7:22 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-23 17:27 ` Juri Linkov
2024-05-24 9:32 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-24 17:38 ` Juri Linkov [this message]
2024-05-26 8:54 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-27 17:52 ` Juri Linkov
2024-05-28 8:05 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-28 16:19 ` Juri Linkov
2024-05-29 8:49 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-30 6:34 ` Juri Linkov
2024-05-30 8:54 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-31 6:18 ` Juri Linkov
2024-05-31 9:45 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-02 6:39 ` Juri Linkov
2024-06-04 8:20 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-04 16:43 ` Juri Linkov
2024-06-05 8:46 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-05 16:48 ` Juri Linkov
2024-06-06 9:19 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-07 6:37 ` Juri Linkov
2024-06-07 8:23 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-07 16:45 ` Juri Linkov
2024-06-08 9:12 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-09 17:04 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86zfsfqgtl.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=70949@debbugs.gnu.org \
--cc=rudalics@gmx.at \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.