aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2002-07-18 14:58:53 +0000
committerRichard M. Stallman2002-07-18 14:58:53 +0000
commitcfabd09347702b319551f8aacb7df317c17d8eeb (patch)
treeca82ebd6467e2ca6447ecd8461e528172b4e8890
parentf0bfada77f91079860d019b65ffd696680b55439 (diff)
downloademacs-cfabd09347702b319551f8aacb7df317c17d8eeb.tar.gz
emacs-cfabd09347702b319551f8aacb7df317c17d8eeb.zip
(last-buffer): Handle buffer-list and buffer-predicate
frame parameters like bury-buffer.
-rw-r--r--lisp/bindings.el24
1 files changed, 20 insertions, 4 deletions
diff --git a/lisp/bindings.el b/lisp/bindings.el
index e4109007953..ab606fa9cc4 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -275,10 +275,26 @@ Keymap for what is displayed by `mode-line-buffer-identification'.")
275 275
276(defun last-buffer () "\ 276(defun last-buffer () "\
277Return the last non-hidden buffer in the buffer list." 277Return the last non-hidden buffer in the buffer list."
278 (let ((list (reverse (buffer-list)))) 278 ;; This logic is more or less copied from bury-buffer,
279 (while (eq (aref (buffer-name (car list)) 0) ? ) 279 ;; except that we reverse the buffer list.
280 (setq list (cdr list))) 280 (let ((fbl (frame-parameter 'buffer-list))
281 (car list))) 281 (list (buffer-list))
282 (pred (frame-parameter nil 'buffer-predicate))
283 found notsogood)
284 ;; Merge the frame buffer list with the whole buffer list,
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) ? )
291 ;; If the selected frame has a buffer_predicate,
292 ;; disregard buffers that don't fit the predicate.
293 (and pred (not (funcall pred (car list)))))
294 (if (get-buffer-window (car list) 'visible)
295 (unless notsogood (setq notsogood (car list)))
296 (setq found (car list)))))
297 (or found notsogood)))
282 298
283(defun unbury-buffer () "\ 299(defun unbury-buffer () "\
284Switch to the last buffer in the buffer list." 300Switch to the last buffer in the buffer list."