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, 17 May 2024 09:40:49 +0300 [thread overview]
Message-ID: <867cft0xt2.fsf@mail.linkov.net> (raw)
In-Reply-To: <f956a47c-56c7-4005-93b4-885c03b05d08@gmx.at> (martin rudalics's message of "Thu, 16 May 2024 10:20:46 +0200")
[-- Attachment #1: Type: text/plain, Size: 1289 bytes --]
>>> Also, we should mention the constraints used for 'lru' and that 'mru'
>>> avoids the selected window here.
>>
>> Sorry, I don't understand what constraints. The docstring of
>> 'display-buffer-use-some-window' doesn't mention any 'lru' constraints.
>
> For historical reasons, 'display-buffer-use-some-window' avoids windows
> that are not full-width and windows on another frame via
>
> (append alist `((lru-frames . ,frame)
> (window-min-width . full-width))))
>
> The default behavior can be overridden with appropriate alist entries
> which are not mentioned in the doc-string but are described in the Elisp
> manual. Your option should mention them because they defy a "strict"
> interpretation of 'lru'.
Thanks for explanations, now these constraints are documented.
> BTW, you could have, instead of an option, provided a 'some-window'
> alist entry with the possible values 'lru', 'mru' or a function. Why
> did you prefer the option?
I already considered adding an alist entry, but the problem is that
it's not clear where users would put it to cover display of all buffers.
But I could reconsider such solution, if you will suggest a suitable place
for users to add such an alist like (some-window . mru) for all buffers.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: display-buffer-use-some-window-method.patch --]
[-- Type: text/x-diff, Size: 2426 bytes --]
diff --git a/lisp/window.el b/lisp/window.el
index 8feeba0d83e..67af4753a70 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -8721,6 +8726,24 @@ display-buffer--lru-window
(setq best-window window))))))
(or best-window second-best-window)))
+(defcustom display-buffer-use-some-window-method 'lru
+ "Which window `display-buffer-use-some-window' should choose.
+The possible choices are `lru' (the default) to select the least
+recently used window, and `mru' to select the most recently used
+window . When a function, it takes two arguments: a buffer and
+an alist, and should return the window where to display the buffer.
+
+When the value is `lru', it avoids selecting windows that are
+not full-width and windows on another frame.
+When the value is `mru', it avoids selecting an already selected window
+and windows on another frame."
+ :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 +8767,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-use-some-window-method '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-use-some-window-method 'mru)
+ (get-mru-window nil nil t))
+ ((functionp display-buffer-use-some-window-method)
+ (funcall display-buffer-use-some-window-method buffer alist)))
(let ((window (get-buffer-window buffer 'visible)))
(unless (and not-this-window
(eq window (selected-window)))
next prev parent reply other threads:[~2024-05-17 6:40 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 [this message]
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
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=867cft0xt2.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.