aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-04-06 08:00:00 +0000
committerRichard M. Stallman1995-04-06 08:00:00 +0000
commit1b40dbedc9cf13a6574d3544cc5204b13dad581d (patch)
treec7b1268bec4595144cd2c815bb62611aa07e3567
parent2f3f993bdf26e374627d311309086acc3418385a (diff)
downloademacs-1b40dbedc9cf13a6574d3544cc5204b13dad581d.tar.gz
emacs-1b40dbedc9cf13a6574d3544cc5204b13dad581d.zip
(list-buffers-noselect): Put buffer name in a text
property on the buffer's name. Put in mouse-face prop here too. Set Buffer-menu-buffer-column here. (Buffer-menu-mode): Don't do those things here. (Buffer-menu-buffer): Use text properties. (Buffer-menu-buffer-name-position): Function deleted.
-rw-r--r--lisp/buff-menu.el55
1 files changed, 26 insertions, 29 deletions
diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el
index 32ae224c1c3..195d08e8002 100644
--- a/lisp/buff-menu.el
+++ b/lisp/buff-menu.el
@@ -127,16 +127,6 @@ Letters do not insert themselves; instead, they are commands.
127 (use-local-map Buffer-menu-mode-map) 127 (use-local-map Buffer-menu-mode-map)
128 (setq major-mode 'Buffer-menu-mode) 128 (setq major-mode 'Buffer-menu-mode)
129 (setq mode-name "Buffer Menu") 129 (setq mode-name "Buffer Menu")
130 (save-excursion
131 (goto-char (point-min))
132 (search-forward "Buffer")
133 (backward-word 1)
134 (setq Buffer-menu-buffer-column (current-column))
135 (forward-line 2)
136 (while (not (eobp))
137 (let ((where (Buffer-menu-buffer-name-position)))
138 (put-text-property (car where) (cdr where) 'mouse-face 'highlight))
139 (forward-line 1)))
140 (make-local-variable 'revert-buffer-function) 130 (make-local-variable 'revert-buffer-function)
141 (setq revert-buffer-function 'Buffer-menu-revert-function) 131 (setq revert-buffer-function 'Buffer-menu-revert-function)
142 (setq truncate-lines t) 132 (setq truncate-lines t)
@@ -148,24 +138,18 @@ Letters do not insert themselves; instead, they are commands.
148 138
149(defun Buffer-menu-buffer (error-if-non-existent-p) 139(defun Buffer-menu-buffer (error-if-non-existent-p)
150 "Return buffer described by this line of buffer menu." 140 "Return buffer described by this line of buffer menu."
151 (let* ((where (Buffer-menu-buffer-name-position)) 141 (let* ((where (save-excursion
152 (string (buffer-substring (car where) (cdr where)))) 142 (beginning-of-line)
153 (set-text-properties 0 (length string) nil string) 143 (+ (point) Buffer-menu-buffer-column)))
154 (or (get-buffer string) 144 (name (get-text-property where 'buffer-name)))
155 (if error-if-non-existent-p 145 (if name
156 (error "No buffer named \"%s\"" string) 146 (or (get-buffer name)
157 nil)))) 147 (if error-if-non-existent-p
158 148 (error "No buffer named `%s'" name)
159;; Find the start and end positions of the buffer name on this line. 149 nil))
160;; Returns a cons (START . END). 150 (if error-if-non-existent-p
161(defun Buffer-menu-buffer-name-position () 151 (error "No buffer on this line")
162 (save-excursion 152 nil))))
163 (beginning-of-line)
164 (forward-char Buffer-menu-buffer-column)
165 (let ((start (point)))
166 (re-search-forward "\t\\| ")
167 (skip-chars-backward " \t")
168 (cons start (point)))))
169 153
170(defun buffer-menu (&optional arg) 154(defun buffer-menu (&optional arg)
171 "Make a menu of buffers so you can save, delete or select them. 155 "Make a menu of buffers so you can save, delete or select them.
@@ -469,11 +453,14 @@ The R column contains a % for buffers that are read-only."
469 MR Buffer Size Mode File 453 MR Buffer Size Mode File
470 -- ------ ---- ---- ---- 454 -- ------ ---- ---- ----
471") 455")
456 ;; Record the column where buffer names start.
457 (setq Buffer-menu-buffer-column 4)
472 (let ((bl (buffer-list))) 458 (let ((bl (buffer-list)))
473 (while bl 459 (while bl
474 (let* ((buffer (car bl)) 460 (let* ((buffer (car bl))
475 (name (buffer-name buffer)) 461 (name (buffer-name buffer))
476 (file (buffer-file-name buffer)) 462 (file (buffer-file-name buffer))
463 this-buffer-line-start
477 this-buffer-read-only 464 this-buffer-read-only
478 this-buffer-size 465 this-buffer-size
479 this-buffer-mode-name 466 this-buffer-mode-name
@@ -498,6 +485,7 @@ The R column contains a % for buffers that are read-only."
498 ((and files-only (not file))) 485 ((and files-only (not file)))
499 ;; Otherwise output info. 486 ;; Otherwise output info.
500 (t 487 (t
488 (setq this-buffer-line-start (point))
501 ;; Identify current buffer. 489 ;; Identify current buffer.
502 (if (eq buffer old-buffer) 490 (if (eq buffer old-buffer)
503 (progn 491 (progn
@@ -507,13 +495,22 @@ The R column contains a % for buffers that are read-only."
507 ;; Identify modified buffers. 495 ;; Identify modified buffers.
508 (princ (if (buffer-modified-p buffer) "*" " ")) 496 (princ (if (buffer-modified-p buffer) "*" " "))
509 ;; Handle readonly status. The output buffer is special 497 ;; Handle readonly status. The output buffer is special
510 ;; cased to be readonly; it is actually made so at a later 498 ;; cased to appear readonly; it is actually made so at a later
511 ;; date. 499 ;; date.
512 (princ (if (or (eq buffer standard-output) 500 (princ (if (or (eq buffer standard-output)
513 this-buffer-read-only) 501 this-buffer-read-only)
514 "% " 502 "% "
515 " ")) 503 " "))
516 (princ name) 504 (princ name)
505 ;; Put the buffer name into a text property
506 ;; so we don't have to extract it from the text.
507 ;; This way we avoid problems with unusual buffer names.
508 (setq this-buffer-line-start
509 (+ this-buffer-line-start Buffer-menu-buffer-column))
510 (put-text-property this-buffer-line-start (point)
511 'buffer-name name)
512 (put-text-property this-buffer-line-start (point)
513 'mouse-face 'highlight)
517 (indent-to 17 2) 514 (indent-to 17 2)
518 (let (size 515 (let (size
519 mode 516 mode