Function: get-mru-frames
get-mru-frames is a byte-compiled function defined in frame.el.gz.
Signature
(get-mru-frames &optional ALL-FRAMES EXCLUDE-CHILD-FRAMES EXCLUDE-FRAME)
Documentation
Return list of frames sorted by most recent use and filtered by ALL-FRAMES.
Compute the result using frame-use-time, which see. Tooltip and
minibuffer only frames are never candidates. If optional argument
EXCLUDE-CHILD-FRAMES is non-nil, eliminate child frames as candidates.
If EXCLUDE-FRAME is non-nil, it is a frame to exclude, for example, the
selected frame.
The following non-nil values of the optional argument ALL-FRAMES have special meanings:
- visible means consider all visible frames on the current terminal
or EXCLUDE-FRAME's terminal if EXCLUDE-FRAME is non-nil.
- 0 (the number zero) means consider all visible and iconified
frames on the current terminal or EXCLUDE-FRAME's terminal if
EXCLUDE-FRAME is non-nil.
Any other value means consider all frames.
Probably introduced at or before Emacs version 31.1.
Source Code
;; Defined in /usr/src/emacs/lisp/frame.el.gz
(defun get-mru-frames (&optional all-frames
exclude-child-frames
exclude-frame)
"Return list of frames sorted by most recent use and filtered by ALL-FRAMES.
Compute the result using `frame-use-time', which see. Tooltip and
minibuffer only frames are never candidates. If optional argument
EXCLUDE-CHILD-FRAMES is non-nil, eliminate child frames as candidates.
If EXCLUDE-FRAME is non-nil, it is a frame to exclude, for example, the
selected frame.
The following non-nil values of the optional argument ALL-FRAMES
have special meanings:
- `visible' means consider all visible frames on the current terminal
or EXCLUDE-FRAME's terminal if EXCLUDE-FRAME is non-nil.
- 0 (the number zero) means consider all visible and iconified
frames on the current terminal or EXCLUDE-FRAME's terminal if
EXCLUDE-FRAME is non-nil.
Any other value means consider all frames."
(setq all-frames (or all-frames t))
(let* ((terminal (frame-terminal (or exclude-frame (selected-frame))))
(frame-list
(seq-remove (lambda (frame)
(or (eq frame exclude-frame)
(eq (frame-parameter frame 'minibuffer) 'only)
(and exclude-child-frames (frame-parent frame))))
(cond
((eq all-frames 'visible)
(seq-filter (lambda (frame)
(eq (frame-terminal frame) terminal))
(visible-frame-list)))
((eq all-frames 0)
(seq-filter (lambda (frame)
(eq (frame-terminal frame) terminal))
(frame-list)))
(t (frame-list))))))
(sort frame-list :key #'frame-use-time :reverse t)))