Function: get-buffer-window-list
get-buffer-window-list is a byte-compiled function defined in
window.el.gz.
Signature
(get-buffer-window-list &optional BUFFER-OR-NAME MINIBUF ALL-FRAMES INDIRECT)
Documentation
Return list of all windows displaying BUFFER-OR-NAME, or nil if none.
BUFFER-OR-NAME may be a buffer or the name of an existing buffer and defaults to the current buffer. If the selected window displays BUFFER-OR-NAME, it will be the first in the resulting list.
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.
INDIRECT non-nil means to append to the list of windows showing
BUFFER-OR-NAME a list of all windows that are indirectly related to
BUFFER-OR-NAME, that is, windows for which window-indirect-buffer-p
with the window and the buffer specified by BUFFER-OR-NAME as arguments
returns non-nil.
Probably introduced at or before Emacs version 19.31.
Source Code
;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun get-buffer-window-list (&optional buffer-or-name minibuf all-frames indirect)
"Return list of all windows displaying BUFFER-OR-NAME, or nil if none.
BUFFER-OR-NAME may be a buffer or the name of an existing buffer
and defaults to the current buffer. If the selected window displays
BUFFER-OR-NAME, it will be the first in the resulting list.
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.
INDIRECT non-nil means to append to the list of windows showing
BUFFER-OR-NAME a list of all windows that are indirectly related to
BUFFER-OR-NAME, that is, windows for which `window-indirect-buffer-p'
with the window and the buffer specified by BUFFER-OR-NAME as arguments
returns non-nil."
(let ((buffer (window-normalize-buffer buffer-or-name))
(window-list (window-list-1 (selected-window) minibuf all-frames))
windows)
(dolist (window window-list)
(when (eq (window-buffer window) buffer)
(setq windows (cons window windows))))
(when indirect
(dolist (window window-list)
(when (window-indirect-buffer-p window buffer)
(setq windows (cons window windows)))))
(nreverse windows)))