Function: walk-windows
walk-windows is a byte-compiled function defined in window.el.gz.
Signature
(walk-windows FUN &optional MINIBUF ALL-FRAMES)
Documentation
Cycle through all live windows, calling FUN for each one.
FUN must specify a function with a window as its sole argument. The optional arguments MINIBUF and ALL-FRAMES specify the set of windows to include in the walk.
MINIBUF t means include the minibuffer window even if the minibuffer is not active. MINIBUF nil or omitted means include the minibuffer window only if the minibuffer is active. Any other value means do not include the minibuffer window even if the minibuffer is active.
ALL-FRAMES nil or omitted means consider all windows on the selected frame, plus the minibuffer window if specified by the MINIBUF argument. If the minibuffer counts, consider all windows on all frames that share that minibuffer too. The following non-nil values of 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.
If ALL-FRAMES specifies a frame, the first window walked is the
first window on that frame (the one returned by frame-first-window),
not necessarily the selected window.
Anything else means consider all windows on the selected frame and no others.
This function changes neither the order of recently selected windows nor the buffer list.
Probably introduced at or before Emacs version 21.1.
Source Code
;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun walk-windows (fun &optional minibuf all-frames)
"Cycle through all live windows, calling FUN for each one.
FUN must specify a function with a window as its sole argument.
The optional arguments MINIBUF and ALL-FRAMES specify the set of
windows to include in the walk.
MINIBUF t means include the minibuffer window even if the
minibuffer is not active. MINIBUF nil or omitted means include
the minibuffer window only if the minibuffer is active. Any
other value means do not include the minibuffer window even if
the minibuffer is active.
ALL-FRAMES nil or omitted means consider all windows on the
selected frame, plus the minibuffer window if specified by the
MINIBUF argument. If the minibuffer counts, consider all windows
on all frames that share that minibuffer too. The following
non-nil values of 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.
If ALL-FRAMES specifies a frame, the first window walked is the
first window on that frame (the one returned by `frame-first-window'),
not necessarily the selected window.
Anything else means consider all windows on the selected frame
and no others.
This function changes neither the order of recently selected
windows nor the buffer list."
;; If we start from the minibuffer window, don't fail to come
;; back to it.
(when (window-minibuffer-p)
(setq minibuf t))
;; Use `save-selected-window' to prevent FUN from messing up
;; the order of windows when it changes the selected window.
(save-selected-window
(dolist (walk-windows-window
(window-list-1 (and (framep all-frames)
(frame-first-window all-frames))
minibuf all-frames))
(funcall fun walk-windows-window))))