Function: walk-window-tree
walk-window-tree is a byte-compiled function defined in window.el.gz.
Signature
(walk-window-tree FUN &optional FRAME ANY MINIBUF)
Documentation
Run function FUN on each live window of FRAME.
FUN must be a function with one argument - a window. FRAME must be a live frame and defaults to the selected one. ANY, if non-nil, means to run FUN on all live and internal windows of FRAME.
Optional argument MINIBUF t means run FUN on FRAME's minibuffer window even if it isn't active. MINIBUF nil or omitted means run FUN on FRAME's minibuffer window only if it's active. In either case the minibuffer window must be part of FRAME. MINIBUF neither nil nor t means never run FUN on the minibuffer window.
This function performs a pre-order, depth-first traversal of the window tree. If FUN changes the window tree, the result is unpredictable.
Source Code
;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun walk-window-tree (fun &optional frame any minibuf)
"Run function FUN on each live window of FRAME.
FUN must be a function with one argument - a window. FRAME must
be a live frame and defaults to the selected one. ANY, if
non-nil, means to run FUN on all live and internal windows of
FRAME.
Optional argument MINIBUF t means run FUN on FRAME's minibuffer
window even if it isn't active. MINIBUF nil or omitted means run
FUN on FRAME's minibuffer window only if it's active. In either
case the minibuffer window must be part of FRAME. MINIBUF
neither nil nor t means never run FUN on the minibuffer window.
This function performs a pre-order, depth-first traversal of the
window tree. If FUN changes the window tree, the result is
unpredictable."
(let ((root (frame-root-window frame))
(mini (minibuffer-window frame)))
(setq frame (window-normalize-frame frame))
(unless (eq root mini)
(walk-window-tree-1 fun root any))
;; Run FUN on FRAME's minibuffer window if requested.
(when (and (window-live-p mini)
(eq (window-frame mini) frame)
(or (eq minibuf t)
(and (not minibuf)
(minibuffer-window-active-p mini))))
(funcall fun mini))))