aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-12-26 04:43:32 +0000
committerRichard M. Stallman1995-12-26 04:43:32 +0000
commit12dcaa7c8e70874ab4fb79b716ecf9b8af065f22 (patch)
tree4125c14acc856e500ef58193f2ca3cedc8450fca
parent1c59f5df964de1ad8e2152d195fd8a34e405338d (diff)
downloademacs-12dcaa7c8e70874ab4fb79b716ecf9b8af065f22.tar.gz
emacs-12dcaa7c8e70874ab4fb79b716ecf9b8af065f22.zip
(mouse-buffer-menu): If lots of buffers, group them into multiple panes.
-rw-r--r--lisp/mouse.el97
1 files changed, 59 insertions, 38 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 98711f4e767..b91f0015263 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -1158,50 +1158,71 @@ This switches buffers in the window that you clicked on,
1158and selects that window." 1158and selects that window."
1159 (interactive "e") 1159 (interactive "e")
1160 (mouse-minibuffer-check event) 1160 (mouse-minibuffer-check event)
1161 (let ((menu 1161 (let* ((buffers
1162 (list "Buffer Menu" 1162 ;; Make an alist of (MENU-ITEM . BUFFER).
1163 (cons "Select Buffer" 1163 (let ((tail (buffer-list))
1164 (let ((tail (buffer-list)) 1164 (maxlen 0)
1165 (maxbuf 0) 1165 head)
1166 head) 1166 (while tail
1167 (while tail 1167 (or (eq ?\ (aref (buffer-name (car tail)) 0))
1168 (or (eq ?\ (aref (buffer-name (car tail)) 0)) 1168 (setq maxlen
1169 (setq maxbuf 1169 (max maxlen
1170 (max maxbuf 1170 (length (buffer-name (car tail))))))
1171 (length (buffer-name (car tail)))))) 1171 (setq tail (cdr tail)))
1172 (setq tail (cdr tail))) 1172 (setq tail (buffer-list))
1173 (setq tail (buffer-list)) 1173 (while tail
1174 (while tail 1174 (let ((elt (car tail)))
1175 (let ((elt (car tail))) 1175 (if (not (string-match "^ "
1176 (if (not (string-match "^ " 1176 (buffer-name elt)))
1177 (buffer-name elt))) 1177 (setq head
1178 (setq head 1178 (cons
1179 (cons 1179 (cons
1180 (cons 1180 (format
1181 (format 1181 (format "%%%ds %%s%%s %%s" maxlen)
1182 (format "%%%ds %%s%%s %%s" maxbuf) 1182 (buffer-name elt)
1183 (buffer-name elt) 1183 (if (buffer-modified-p elt) "*" " ")
1184 (if (buffer-modified-p elt) "*" " ") 1184 (save-excursion
1185 (save-excursion 1185 (set-buffer elt)
1186 (set-buffer elt) 1186 (if buffer-read-only "%" " "))
1187 (if buffer-read-only "%" " ")) 1187 (or (buffer-file-name elt)
1188 (or (buffer-file-name elt) 1188 (save-excursion
1189 (save-excursion 1189 (set-buffer elt)
1190 (set-buffer elt) 1190 (if list-buffers-directory
1191 (if list-buffers-directory 1191 (expand-file-name
1192 (expand-file-name 1192 list-buffers-directory)))
1193 list-buffers-directory))) 1193 ""))
1194 "")) 1194 elt)
1195 elt) 1195 head))))
1196 head)))) 1196 (setq tail (cdr tail)))
1197 (setq tail (cdr tail))) 1197 head))
1198 (reverse head)))))) 1198 (menu
1199 ;; If we have lots of buffers, divide them into groups of 20
1200 ;; and make a pane (or submenu) for each one.
1201 (if (> (length buffers) 30)
1202 (let ((buffers (reverse buffers)) sublists next
1203 (i 1))
1204 (while buffers
1205 ;; Pull off the next 20 buffers
1206 ;; and make them the next element of sublist.
1207 (setq next (nthcdr 20 buffers))
1208 (if next
1209 (setcdr (nthcdr 19 buffers) nil))
1210 (setq sublists (cons (cons (format "Buffers %d" i) buffers)
1211 sublists))
1212 (setq i (1+ i))
1213 (setq buffers next))
1214 (cons "Buffer Menu" (nreverse sublists)))
1215 ;; Few buffers--put them all in one pane.
1216 (list "Buffer Menu" (cons "Select Buffer" buffers)))))
1217 (setq foo menu)
1199 (let ((buf (x-popup-menu event menu)) 1218 (let ((buf (x-popup-menu event menu))
1200 (window (posn-window (event-start event)))) 1219 (window (posn-window (event-start event))))
1201 (if buf 1220 (if buf
1202 (progn 1221 (progn
1203 (or (framep window) (select-window window)) 1222 (or (framep window) (select-window window))
1204 (switch-to-buffer buf)))))) 1223 (switch-to-buffer buf))))))
1224
1225(defun mouse-buffer-menu-split (alist)
1205 1226
1206;;; These need to be rewritten for the new scroll bar implementation. 1227;;; These need to be rewritten for the new scroll bar implementation.
1207 1228