Function: last-buffer

last-buffer is a byte-compiled function defined in window.el.gz.

Signature

(last-buffer &optional BUFFER VISIBLE-OK FRAME)

Documentation

Return the last buffer in FRAME's buffer list.

If BUFFER is the last buffer, return the preceding buffer instead. Buffers not visible in windows are preferred to visible buffers, unless optional argument VISIBLE-OK is non-nil. Optional third argument FRAME nil or omitted means use the selected frame's buffer list. If no such buffer exists, return the buffer *scratch*, creating it if necessary.

Source Code

;; Defined in /usr/src/emacs/lisp/window.el.gz
(defun last-buffer (&optional buffer visible-ok frame)
  "Return the last buffer in FRAME's buffer list.
If BUFFER is the last buffer, return the preceding buffer
instead.  Buffers not visible in windows are preferred to visible
buffers, unless optional argument VISIBLE-OK is non-nil.
Optional third argument FRAME nil or omitted means use the
selected frame's buffer list.  If no such buffer exists, return
the buffer `*scratch*', creating it if necessary."
  (setq frame (or frame (selected-frame)))
  (or (get-next-valid-buffer (nreverse (buffer-list frame))
                             buffer visible-ok frame)
      (get-buffer "*scratch*")
      (let ((scratch (get-buffer-create "*scratch*")))
	(set-buffer-major-mode scratch)
	scratch)))