Function: display-buffer--lru-window
display-buffer--lru-window is a byte-compiled function defined in
window.el.gz.
Signature
(display-buffer--lru-window ALIST)
Documentation
Return the least recently used window according to ALIST.
Do not return a minibuffer window or a window dedicated to its
buffer. ALIST is a buffer display action alist as compiled by
display-buffer. The following ALIST entries are honored:
- lru-frames specifies the frames to investigate and has the
same meaning as the ALL-FRAMES argument of get-lru-window.
- lru-time specifies a use time. Do not return a window whose
use time is higher than this.
- window-min-width specifies a preferred minimum width in
canonical frame columns. If it is the symbol full-width,
prefer a full-width window.
- window-min-height specifies a preferred minimum height in
canonical frame lines. If it is the symbol full-height,
prefer a full-height window.
If ALIST contains a non-nil inhibit-same-window entry, do not
return the selected window.
Source Code
;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun display-buffer--lru-window (alist)
"Return the least recently used window according to ALIST.
Do not return a minibuffer window or a window dedicated to its
buffer. ALIST is a buffer display action alist as compiled by
`display-buffer'. The following ALIST entries are honored:
- `lru-frames' specifies the frames to investigate and has the
same meaning as the ALL-FRAMES argument of `get-lru-window'.
- `lru-time' specifies a use time. Do not return a window whose
use time is higher than this.
- `window-min-width' specifies a preferred minimum width in
canonical frame columns. If it is the symbol `full-width',
prefer a full-width window.
- `window-min-height' specifies a preferred minimum height in
canonical frame lines. If it is the symbol `full-height',
prefer a full-height window.
If ALIST contains a non-nil `inhibit-same-window' entry, do not
return the selected window."
(let ((windows
(window-list-1 nil 'nomini (cdr (assq 'lru-frames alist))))
(lru-time (cdr (assq 'lru-time alist)))
(min-width (cdr (assq 'window-min-width alist)))
(min-height (cdr (assq 'window-min-height alist)))
(not-this-window (cdr (assq 'inhibit-same-window alist)))
best-window best-time second-best-window second-best-time time)
(dolist (window windows)
(when (and (not (window-dedicated-p window))
(or (not not-this-window)
(not (eq window (selected-window)))))
(setq time (window-use-time window))
(unless (and (numberp lru-time) (> time lru-time))
(if (or (eq window (selected-window))
(and min-width
(or (and (numberp min-width)
(< (window-width window) min-width))
(and (eq min-width 'full-width)
(not (window-full-width-p window)))))
(and min-height
(or (and (numberp min-height)
(< (window-height window) min-height))
(and (eq min-height 'full-height)
(not (window-full-height-p window))))))
;; This window is either selected or does not meet the size
;; restrictions - so it's only a second best choice. Try to
;; find a more recently used one that fits.
(when (or (not second-best-time) (< time second-best-time))
(setq second-best-time time)
(setq second-best-window window))
;; This window is not selected and does meet the size
;; restrictions. It's the best choice so far.
(when (or (not best-time) (< time best-time))
(setq best-time time)
(setq best-window window))))))
(or best-window second-best-window)))