comparison lisp/simple.el @ 100803:0186716f4b63

(last-buffer): Don't set major mode of *scratch* if that buffer exists already. Rewrite doc-string.
author Martin Rudalics <rudalics@gmx.at>
date Wed, 31 Dec 2008 15:44:25 +0000
parents 5a144164af93
children 8bebf3521844
comparison
equal deleted inserted replaced
100802:ded357c75f85 100803:0186716f4b63
76 (setq found buf) 76 (setq found buf)
77 (setq list (cdr list)))) 77 (setq list (cdr list))))
78 (car list))) 78 (car list)))
79 79
80 (defun last-buffer (&optional buffer visible-ok frame) 80 (defun last-buffer (&optional buffer visible-ok frame)
81 "Return the last non-hidden displayable buffer in the buffer list. 81 "Return the last buffer in FRAME's buffer list.
82 If BUFFER is non-nil, last-buffer will ignore that buffer. 82 If BUFFER is the last buffer, return the preceding buffer instead.
83 Buffers not visible in windows are preferred to visible buffers, 83 Buffers not visible in windows are preferred to visible buffers,
84 unless optional argument VISIBLE-OK is non-nil. 84 unless optional argument VISIBLE-OK is non-nil.
85 If the optional third argument FRAME is non-nil, use that frame's 85 Optional third argument FRAME nil or omitted means use the
86 buffer list instead of the selected frame's buffer list. 86 selected frame's buffer list.
87 If no other buffer exists, the buffer `*scratch*' is returned." 87 If no such buffer exists, return the buffer `*scratch*', creating
88 it if necessary."
88 (setq frame (or frame (selected-frame))) 89 (setq frame (or frame (selected-frame)))
89 (or (get-next-valid-buffer (nreverse (buffer-list frame)) 90 (or (get-next-valid-buffer (nreverse (buffer-list frame))
90 buffer visible-ok frame) 91 buffer visible-ok frame)
91 (progn 92 (get-buffer "*scratch*")
92 (set-buffer-major-mode (get-buffer-create "*scratch*")) 93 (let ((scratch (get-buffer-create "*scratch*")))
93 (get-buffer "*scratch*")))) 94 (set-buffer-major-mode scratch)
95 scratch)))
96
94 (defun next-buffer () 97 (defun next-buffer ()
95 "Switch to the next buffer in cyclic order." 98 "Switch to the next buffer in cyclic order."
96 (interactive) 99 (interactive)
97 (let ((buffer (current-buffer))) 100 (let ((buffer (current-buffer)))
98 (switch-to-buffer (other-buffer buffer t)) 101 (switch-to-buffer (other-buffer buffer t))