Function: get-mru-window
get-mru-window is a byte-compiled function defined in window.el.gz.
Signature
(get-mru-window &optional ALL-FRAMES DEDICATED NOT-SELECTED NO-OTHER)
Documentation
Return the most recently used window on frames specified by ALL-FRAMES.
A minibuffer window is never a candidate. A dedicated window is never a
candidate unless DEDICATED is non-nil, so if all windows are dedicated,
the value is nil. Optional argument NOT-SELECTED non-nil means never
return the selected window. Optional argument NO-OTHER non-nil means to
never return a window for which window-no-other-p returns non-nil.
The following non-nil values of the optional argument ALL-FRAMES have special meanings:
- t means consider all windows on all existing frames.
- visible means consider all windows on all visible frames on
the current terminal.
- 0 (the number zero) means consider all windows on all visible
and iconified frames on the current terminal.
- A frame means consider all windows on that frame only.
Any other value of ALL-FRAMES means consider all windows on the selected frame and no others.
Probably introduced at or before Emacs version 24.3.
Source Code
;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun get-mru-window (&optional all-frames dedicated not-selected no-other)
"Return the most recently used window on frames specified by ALL-FRAMES.
A minibuffer window is never a candidate. A dedicated window is never a
candidate unless DEDICATED is non-nil, so if all windows are dedicated,
the value is nil. Optional argument NOT-SELECTED non-nil means never
return the selected window. Optional argument NO-OTHER non-nil means to
never return a window for which `window-no-other-p' returns non-nil.
The following non-nil values of the optional argument ALL-FRAMES
have special meanings:
- t means consider all windows on all existing frames.
- `visible' means consider all windows on all visible frames on
the current terminal.
- 0 (the number zero) means consider all windows on all visible
and iconified frames on the current terminal.
- A frame means consider all windows on that frame only.
Any other value of ALL-FRAMES means consider all windows on the
selected frame and no others."
(let (best-window best-time time)
(dolist (window (window-list-1 nil 'nomini all-frames))
(setq time (window-use-time window))
(when (and (or dedicated (not (window-dedicated-p window)))
(or (not not-selected) (not (eq window (selected-window))))
(or (not no-other) (not (window-no-other-p window)))
(or (not best-time) (> time best-time)))
(setq best-time time)
(setq best-window window)))
best-window))