diff options
author | Richard M. Stallman <rms@gnu.org> | 2002-07-18 14:58:53 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 2002-07-18 14:58:53 +0000 |
commit | 531e62c82fd8531ccfec77bbba84f10c0cd5c909 (patch) | |
tree | f0a4c033a75e809dc6cec26737dad01c684c21b5 /lisp/bindings.el | |
parent | 320c9704840c426f54cb8daa67a7576942163e78 (diff) | |
download | emacs-531e62c82fd8531ccfec77bbba84f10c0cd5c909.tar.gz |
(last-buffer): Handle buffer-list and buffer-predicate
frame parameters like bury-buffer.
Diffstat (limited to 'lisp/bindings.el')
-rw-r--r-- | lisp/bindings.el | 24 |
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'.") (defun last-buffer () "\ Return the last non-hidden buffer in the buffer list." - (let ((list (reverse (buffer-list)))) - (while (eq (aref (buffer-name (car list)) 0) ? ) - (setq list (cdr list))) - (car list))) + ;; This logic is more or less copied from bury-buffer, + ;; except that we reverse the buffer list. + (let ((fbl (frame-parameter 'buffer-list)) + (list (buffer-list)) + (pred (frame-parameter nil 'buffer-predicate)) + found notsogood) + ;; Merge the frame buffer list with the whole buffer list, + ;; and reverse it. + (dolist (buffer fbl) + (setq list (delq buffer list))) + (setq list (nreverse (append fbl list))) + (while (not found) + (unless (or (eq (aref (buffer-name (car list)) 0) ? ) + ;; If the selected frame has a buffer_predicate, + ;; disregard buffers that don't fit the predicate. + (and pred (not (funcall pred (car list))))) + (if (get-buffer-window (car list) 'visible) + (unless notsogood (setq notsogood (car list))) + (setq found (car list))))) + (or found notsogood))) (defun unbury-buffer () "\ Switch to the last buffer in the buffer list." |