Function: get-window-with-predicate

get-window-with-predicate is a byte-compiled function defined in window.el.gz.

Signature

(get-window-with-predicate PREDICATE &optional MINIBUF ALL-FRAMES DEFAULT)

Documentation

Return a live window satisfying PREDICATE.

More precisely, cycle through all windows calling the function PREDICATE on each one of them with the window as its sole argument. Return the first window for which PREDICATE returns non-nil. Windows are scanned starting with the window following the selected window. If no window satisfies PREDICATE, return DEFAULT.

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.

Anything else means consider all windows on the selected frame and no others.

View in manual

Probably introduced at or before Emacs version 21.1.

Aliases

some-window

Source Code

;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun get-window-with-predicate (predicate &optional minibuf all-frames default)
  "Return a live window satisfying PREDICATE.
More precisely, cycle through all windows calling the function
PREDICATE on each one of them with the window as its sole
argument.  Return the first window for which PREDICATE returns
non-nil.  Windows are scanned starting with the window following
the selected window.  If no window satisfies PREDICATE, return
DEFAULT.

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.

Anything else means consider all windows on the selected frame
and no others."
  (catch 'found
    (dolist (window (window-list-1
		     (next-window nil minibuf all-frames)
		     minibuf all-frames))
      (when (funcall predicate window)
	(throw 'found window)))
    default))