Function: get-next-valid-buffer
get-next-valid-buffer is a byte-compiled function defined in
window.el.gz.
Signature
(get-next-valid-buffer LIST &optional BUFFER VISIBLE-OK FRAME)
Documentation
Search LIST for a valid buffer to display in FRAME.
Return nil when all buffers in LIST are undesirable for display, otherwise return the first suitable buffer in LIST.
Buffers not visible in windows are preferred to visible buffers, unless VISIBLE-OK is non-nil. If the optional argument FRAME is nil, it defaults to the selected frame. If BUFFER is non-nil, ignore occurrences of that buffer in LIST.
Source Code
;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun get-next-valid-buffer (list &optional buffer visible-ok frame)
"Search LIST for a valid buffer to display in FRAME.
Return nil when all buffers in LIST are undesirable for display,
otherwise return the first suitable buffer in LIST.
Buffers not visible in windows are preferred to visible buffers,
unless VISIBLE-OK is non-nil.
If the optional argument FRAME is nil, it defaults to the selected frame.
If BUFFER is non-nil, ignore occurrences of that buffer in LIST."
;; This logic is more or less copied from other-buffer.
(setq frame (or frame (selected-frame)))
(let ((pred (frame-parameter frame 'buffer-predicate))
found buf)
(while (and (not found) list)
(setq buf (car list))
(if (and (not (eq buffer buf))
(buffer-live-p buf)
(or (null pred) (funcall pred buf))
(not (eq (aref (buffer-name buf) 0) ?\s))
(or visible-ok (null (get-buffer-window buf 'visible))))
(setq found buf)
(setq list (cdr list))))
(car list)))