diff options
| author | Richard M. Stallman | 1995-01-30 02:15:37 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-01-30 02:15:37 +0000 |
| commit | e1fd0a89b067e8d4c2bb319fec04ce498adb5d28 (patch) | |
| tree | 1d758ccd005d5946ecffe7c9233c337e61d91b2a | |
| parent | 08c82d4d499198ab091f76c05be274a5ba4f1d67 (diff) | |
| download | emacs-e1fd0a89b067e8d4c2bb319fec04ce498adb5d28.tar.gz emacs-e1fd0a89b067e8d4c2bb319fec04ce498adb5d28.zip | |
(list-buffers-noselect): Handle read-only properly.
Select each buffer just once to get all necessary info about it.
| -rw-r--r-- | lisp/buff-menu.el | 52 |
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." | |||
| 473 | (while bl | 473 | (while bl |
| 474 | (let* ((buffer (car bl)) | 474 | (let* ((buffer (car bl)) |
| 475 | (name (buffer-name buffer)) | 475 | (name (buffer-name buffer)) |
| 476 | (file (buffer-file-name buffer))) | 476 | (file (buffer-file-name buffer)) |
| 477 | this-buffer-read-only | ||
| 478 | this-buffer-size | ||
| 479 | this-buffer-mode-name | ||
| 480 | this-buffer-directory) | ||
| 481 | (save-excursion | ||
| 482 | (set-buffer buffer) | ||
| 483 | (setq this-buffer-read-only buffer-read-only) | ||
| 484 | (setq this-buffer-size (buffer-size)) | ||
| 485 | (setq this-buffer-mode-name | ||
| 486 | (if (eq buffer standard-output) | ||
| 487 | "Buffer Menu" mode-name)) | ||
| 488 | (or file | ||
| 489 | ;; No visited file. Check local value of | ||
| 490 | ;; list-buffers-directory. | ||
| 491 | (if (and (boundp 'list-buffers-directory) | ||
| 492 | list-buffers-directory) | ||
| 493 | (setq this-buffer-directory list-buffers-directory)))) | ||
| 477 | (cond | 494 | (cond |
| 478 | ;; Don't mention internal buffers. | 495 | ;; Don't mention internal buffers. |
| 479 | ((string= (substring name 0 1) " ")) | 496 | ((string= (substring name 0 1) " ")) |
| @@ -492,7 +509,8 @@ The R column contains a % for buffers that are read-only." | |||
| 492 | ;; Handle readonly status. The output buffer is special | 509 | ;; Handle readonly status. The output buffer is special |
| 493 | ;; cased to be readonly; it is actually made so at a later | 510 | ;; cased to be readonly; it is actually made so at a later |
| 494 | ;; date. | 511 | ;; date. |
| 495 | (princ (if (or (eq buffer standard-output) buffer-read-only) | 512 | (princ (if (or (eq buffer standard-output) |
| 513 | this-buffer-read-only) | ||
| 496 | "% " | 514 | "% " |
| 497 | " ")) | 515 | " ")) |
| 498 | (princ name) | 516 | (princ name) |
| @@ -500,31 +518,19 @@ The R column contains a % for buffers that are read-only." | |||
| 500 | (let (size | 518 | (let (size |
| 501 | mode | 519 | mode |
| 502 | (excess (- (current-column) 17))) | 520 | (excess (- (current-column) 17))) |
| 503 | (save-excursion | 521 | (setq size (format "%8d" this-buffer-size)) |
| 504 | (set-buffer buffer) | 522 | ;; Ack -- if looking at the *Buffer List* buffer, |
| 505 | (setq size (format "%8d" (buffer-size))) | 523 | ;; always use "Buffer Menu" mode. Otherwise the |
| 506 | ;; Ack -- if looking at the *Buffer List* buffer, | 524 | ;; first time the buffer is created, the mode will be wrong. |
| 507 | ;; always use "Buffer Menu" mode. Otherwise the | 525 | (setq mode this-buffer-mode-name) |
| 508 | ;; first time the buffer is created, the mode will | 526 | (while (and (> excess 0) (= (aref size 0) ?\ )) |
| 509 | ;; be wrong. | 527 | (setq size (substring size 1)) |
| 510 | (setq mode (if (eq buffer standard-output) | 528 | (setq excess (1- excess))) |
| 511 | "Buffer Menu" | ||
| 512 | mode-name)) | ||
| 513 | (while (and (> excess 0) (= (aref size 0) ?\ )) | ||
| 514 | (setq size (substring size 1)) | ||
| 515 | (setq excess (1- excess)))) | ||
| 516 | (princ size) | 529 | (princ size) |
| 517 | (indent-to 27 1) | 530 | (indent-to 27 1) |
| 518 | (princ mode)) | 531 | (princ mode)) |
| 519 | (indent-to 40 1) | 532 | (indent-to 40 1) |
| 520 | (or file | 533 | (or file (setq file this-buffer-directory)) |
| 521 | ;; No visited file. Check local value of | ||
| 522 | ;; list-buffers-directory. | ||
| 523 | (save-excursion | ||
| 524 | (set-buffer buffer) | ||
| 525 | (if (and (boundp 'list-buffers-directory) | ||
| 526 | list-buffers-directory) | ||
| 527 | (setq file list-buffers-directory)))) | ||
| 528 | (if file | 534 | (if file |
| 529 | (princ file)) | 535 | (princ file)) |
| 530 | (princ "\n")))) | 536 | (princ "\n")))) |