comparison lisp/bindings.el @ 46597:ea15c9ca1d86

(last-buffer): Use buffer-list with frame arg. Create *scratch* if no other choice exists. Fix bugs.
author Richard M. Stallman <rms@gnu.org>
date Sun, 21 Jul 2002 20:23:32 +0000
parents 0cdc8b745baf
children 378639c31552
comparison
equal deleted inserted replaced
46596:5502ee23a19b 46597:ea15c9ca1d86
275 275
276 (defun last-buffer () "\ 276 (defun last-buffer () "\
277 Return the last non-hidden buffer in the buffer list." 277 Return the last non-hidden buffer in the buffer list."
278 ;; This logic is more or less copied from bury-buffer, 278 ;; This logic is more or less copied from bury-buffer,
279 ;; except that we reverse the buffer list. 279 ;; except that we reverse the buffer list.
280 (let ((fbl (frame-parameter nil 'buffer-list)) 280 (let ((list (nreverse (buffer-list (selected-frame))))
281 (list (buffer-list))
282 (pred (frame-parameter nil 'buffer-predicate)) 281 (pred (frame-parameter nil 'buffer-predicate))
283 found notsogood) 282 found notsogood)
284 ;; Merge the frame buffer list with the whole buffer list, 283 (while (and list (not found))
285 ;; and reverse it.
286 (dolist (buffer fbl)
287 (setq list (delq buffer list)))
288 (setq list (nreverse (append fbl list)))
289 (while (not found)
290 (unless (or (eq (aref (buffer-name (car list)) 0) ? ) 284 (unless (or (eq (aref (buffer-name (car list)) 0) ? )
291 ;; If the selected frame has a buffer_predicate, 285 ;; If the selected frame has a buffer_predicate,
292 ;; disregard buffers that don't fit the predicate. 286 ;; disregard buffers that don't fit the predicate.
293 (and pred (not (funcall pred (car list))))) 287 (and pred (not (funcall pred (car list)))))
294 (if (get-buffer-window (car list) 'visible) 288 (if (get-buffer-window (car list) 'visible)
295 (unless notsogood (setq notsogood (car list))) 289 (or notsogood (eq (car list) (current-buffer)))
296 (setq found (car list))))) 290 (setq found (car list))))
297 (or found notsogood))) 291 (pop list))
292 (or found notsogood
293 (get-buffer "*scratch*")
294 (progn
295 (set-buffer-major-mode
296 (get-buffer-create "*scratch*"))
297 (get-buffer "*scratch*")))))
298 298
299 (defun unbury-buffer () "\ 299 (defun unbury-buffer () "\
300 Switch to the last buffer in the buffer list." 300 Switch to the last buffer in the buffer list."
301 (interactive) 301 (interactive)
302 (switch-to-buffer (last-buffer))) 302 (switch-to-buffer (last-buffer)))