GNU Emacs Lisp Reference Manual
The buffer list is a list of all live buffers. Creating a
buffer adds it to this list, and killing a buffer deletes it. The order
of the buffers in the list is based primarily on how recently each
buffer has been displayed in the selected window. Buffers move to the
front of the list when they are selected and to the end when they are
buried. Several functions, notably other-buffer, use this
ordering. A buffer list displayed for the user also follows this order.
(buffer-list)
=> (#<buffer buffers.texi>
#<buffer *Minibuf-1*> #<buffer buffer.c>
#<buffer *Help*> #<buffer TAGS>)
;; Note that the name of the minibuffer
;; begins with a space!
(mapcar (function buffer-name) (buffer-list))
=> ("buffers.texi" " *Minibuf-1*"
"buffer.c" "*Help*" "TAGS")
This list is a copy of a list used inside Emacs; modifying it has no effect on the ordering of buffers.
If buffer-or-name is not supplied (or if it is not a buffer),
then other-buffer returns the first buffer on the buffer list
that is not visible in any window in a visible frame.
If the selected frame has a non-nil buffer-predicate
parameter, then other-buffer uses that predicate to decide which
buffers to consider. It calls the predicate once for each buffer, and
if the value is nil, that buffer is ignored. See X Frame Parameters.
If visible-ok is nil, other-buffer avoids returning
a buffer visible in any window on any visible frame, except as a last
resort. If visible-ok is non-nil, then it does not matter
whether a buffer is displayed somewhere or not.
If no suitable buffer exists, the buffer *scratch* is returned
(and created, if necessary).
other-buffer to return.
If buffer-or-name is nil or omitted, this means to bury the
current buffer. In addition, if the buffer is displayed in the selected
window, this switches to some other buffer (obtained using
other-buffer) in the selected window. But if the buffer is
displayed in some other window, it remains displayed there.
If you wish to replace a buffer in all the windows that display it, use
replace-buffer-in-windows. See Buffers and Windows.