summaryrefslogtreecommitdiff
path: root/lisp/buff-menu.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1995-01-30 02:15:37 +0000
committerRichard M. Stallman <rms@gnu.org>1995-01-30 02:15:37 +0000
commitf43931a7f0dc1bd4a317d73ebe56aabc27acca5b (patch)
tree67799597d47130a13ab9869ff7a481f5ba34bc95 /lisp/buff-menu.el
parent0821d0854280879835ed97c293b27363371f1f22 (diff)
downloademacs-f43931a7f0dc1bd4a317d73ebe56aabc27acca5b.tar.gz
(list-buffers-noselect): Handle read-only properly.
Select each buffer just once to get all necessary info about it.
Diffstat (limited to 'lisp/buff-menu.el')
-rw-r--r--lisp/buff-menu.el52
1 files changed, 29 insertions, 23 deletions
diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el
index 7652594646c..a33f72a7fcc 100644
--- a/lisp/buff-menu.el
+++ b/lisp/buff-menu.el
@@ -473,7 +473,24 @@ The R column contains a % for buffers that are read-only."
(while bl
(let* ((buffer (car bl))
(name (buffer-name buffer))
- (file (buffer-file-name buffer)))
+ (file (buffer-file-name buffer))
+ this-buffer-read-only
+ this-buffer-size
+ this-buffer-mode-name
+ this-buffer-directory)
+ (save-excursion
+ (set-buffer buffer)
+ (setq this-buffer-read-only buffer-read-only)
+ (setq this-buffer-size (buffer-size))
+ (setq this-buffer-mode-name
+ (if (eq buffer standard-output)
+ "Buffer Menu" mode-name))
+ (or file
+ ;; No visited file. Check local value of
+ ;; list-buffers-directory.
+ (if (and (boundp 'list-buffers-directory)
+ list-buffers-directory)
+ (setq this-buffer-directory list-buffers-directory))))
(cond
;; Don't mention internal buffers.
((string= (substring name 0 1) " "))
@@ -492,7 +509,8 @@ The R column contains a % for buffers that are read-only."
;; Handle readonly status. The output buffer is special
;; cased to be readonly; it is actually made so at a later
;; date.
- (princ (if (or (eq buffer standard-output) buffer-read-only)
+ (princ (if (or (eq buffer standard-output)
+ this-buffer-read-only)
"% "
" "))
(princ name)
@@ -500,31 +518,19 @@ The R column contains a % for buffers that are read-only."
(let (size
mode
(excess (- (current-column) 17)))
- (save-excursion
- (set-buffer buffer)
- (setq size (format "%8d" (buffer-size)))
- ;; Ack -- if looking at the *Buffer List* buffer,
- ;; always use "Buffer Menu" mode. Otherwise the
- ;; first time the buffer is created, the mode will
- ;; be wrong.
- (setq mode (if (eq buffer standard-output)
- "Buffer Menu"
- mode-name))
- (while (and (> excess 0) (= (aref size 0) ?\ ))
- (setq size (substring size 1))
- (setq excess (1- excess))))
+ (setq size (format "%8d" this-buffer-size))
+ ;; Ack -- if looking at the *Buffer List* buffer,
+ ;; always use "Buffer Menu" mode. Otherwise the
+ ;; first time the buffer is created, the mode will be wrong.
+ (setq mode this-buffer-mode-name)
+ (while (and (> excess 0) (= (aref size 0) ?\ ))
+ (setq size (substring size 1))
+ (setq excess (1- excess)))
(princ size)
(indent-to 27 1)
(princ mode))
(indent-to 40 1)
- (or file
- ;; No visited file. Check local value of
- ;; list-buffers-directory.
- (save-excursion
- (set-buffer buffer)
- (if (and (boundp 'list-buffers-directory)
- list-buffers-directory)
- (setq file list-buffers-directory))))
+ (or file (setq file this-buffer-directory))
(if file
(princ file))
(princ "\n"))))