From: Juri Linkov <juri@linkov.net>
To: 70949@debbugs.gnu.org
Cc: martin rudalics <rudalics@gmx.at>
Subject: bug#70949: display-buffer-choose-some-window
Date: Tue, 14 May 2024 19:56:27 +0300 [thread overview]
Message-ID: <86jzjwqqmd.fsf@mail.linkov.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 955 bytes --]
Addressing the request in help-gnu-emacs quoted below:
>> When cycling through, say, a rgrep result buffer with n
>> (next-error-no-select) and p (previous-error-no-select), file results
>> are displayed in every open window, with the exception of the window
>> containing the rgrep results themselves.
>>
>> I'd rather have file results remain in just one window so that I can use
>> other buffers while still viewing search results. Is this possible?
>>
>> How would I go about this? Are there any better options?
>
> The problem is that the first thing that
> 'display-buffer-use-some-window' tries to do
> is to find the least recently used window
> with 'display-buffer--lru-window'.
>
> I think this behavior should be customizable with a new option,
> so that you could prefer always to use
> the most recently used window.
here is a patch that adds such option that allows to customize
what window display-buffer-use-some-window should prefer:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: display-buffer-choose-some-window.patch --]
[-- Type: text/x-diff, Size: 2280 bytes --]
diff --git a/lisp/window.el b/lisp/window.el
index 8feeba0d83e..d34e369167e 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -8721,6 +8726,22 @@ display-buffer--lru-window
(setq best-window window))))))
(or best-window second-best-window)))
+(defcustom display-buffer-choose-some-window 'lru
+ "How to choose an existing window.
+This defines a strategy of choosing some window
+by `display-buffer-use-some-window'.
+
+The possible choices are `lru' (the default) to select the least recently
+used window on that frame, and `mru' to select the most recently used
+window on that frame. When a function, it takes two arguments: a buffer
+and an alist, and should return the window where to display the buffer."
+ :type '(choice (const :tag "Least recently used" lru)
+ (const :tag "Most recently used" mru)
+ (function :tag "Custom function"))
+ :group 'windows
+ :group 'frames
+ :version "30.1")
+
(defun display-buffer-use-some-window (buffer alist)
"Display BUFFER in an existing window.
Search for a usable window, set that window to the buffer, and
@@ -8743,11 +8764,17 @@ display-buffer-use-some-window
(window--frame-usable-p (last-nonminibuffer-frame))))
(window
;; Reuse an existing window.
- (or (display-buffer--lru-window
- ;; If ALIST specifies 'lru-frames' or 'window-min-width'
- ;; let them prevail.
- (append alist `((lru-frames . ,frame)
- (window-min-width . full-width))))
+ (or (cond
+ ((eq display-buffer-choose-some-window 'lru)
+ (display-buffer--lru-window
+ ;; If ALIST specifies 'lru-frames' or 'window-min-width'
+ ;; let them prevail.
+ (append alist `((lru-frames . ,frame)
+ (window-min-width . full-width)))))
+ ((eq display-buffer-choose-some-window 'mru)
+ (get-mru-window nil nil t))
+ ((functionp display-buffer-choose-some-window)
+ (funcall display-buffer-choose-some-window buffer alist)))
(let ((window (get-buffer-window buffer 'visible)))
(unless (and not-this-window
(eq window (selected-window)))
next reply other threads:[~2024-05-14 16:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-14 16:56 Juri Linkov [this message]
2024-05-15 8:06 ` bug#70949: display-buffer-choose-some-window 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
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
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=86jzjwqqmd.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 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).