aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Bader2002-04-23 05:02:14 +0000
committerMiles Bader2002-04-23 05:02:14 +0000
commit8b621d39e2916b4c4edc158c55cbefce6bd8e66b (patch)
tree266b2dc212cb4e3be8e3301cc00f682ccb7cacb7
parenta74357d4eaaa0d24c674d19380c395048392ffea (diff)
downloademacs-8b621d39e2916b4c4edc158c55cbefce6bd8e66b.tar.gz
emacs-8b621d39e2916b4c4edc158c55cbefce6bd8e66b.zip
(menu-bar-update-buffers): Add `Select Named Buffer'.
Add separator line before commands Remove old crufty code that tried to line things up by adding spaces to entries (it doesn't work). Move `Frames' submenu after the normal buffers, and add a separator line before it. (menu-bar-buffers-menu-list-buffers-entry): Variable removed.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/menu-bar.el171
2 files changed, 85 insertions, 98 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e9bb0e76234..a9c7da1ed7e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12002-04-23 Miles Bader <miles@gnu.org>
2
3 * menu-bar.el (menu-bar-update-buffers): Add `Select Named Buffer'.
4 Add separator line before commands
5 Remove old crufty code that tried to line things up by adding
6 spaces to entries (it doesn't work).
7 Move `Frames' submenu after the normal buffers, and add a
8 separator line before it.
9 (menu-bar-buffers-menu-list-buffers-entry): Variable removed.
10
12002-04-22 Richard M. Stallman <rms@gnu.org> 112002-04-22 Richard M. Stallman <rms@gnu.org>
2 12
3 * files.el (after-find-file): Use %s to output MSG. 13 * files.el (after-find-file): Use %s to output MSG.
@@ -18,7 +28,7 @@
18 when finding the end. Take more care in analyzing the results 28 when finding the end. Take more care in analyzing the results
19 of intangibility after line-move-to-column. 29 of intangibility after line-move-to-column.
20 30
212002-04-22 Pavel Jan,Bm(Bk <Pavel@Janik.cz> 312002-04-22 Pavel Jan,Am(Bk <Pavel@Janik.cz>
22 32
23 * international/mule-diag.el (list-input-methods-1): Doc fix 33 * international/mule-diag.el (list-input-methods-1): Doc fix
24 (LEIM is now part of the standard distribution). 34 (LEIM is now part of the standard distribution).
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index f933b135bef..e7a6eed9877 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -1282,15 +1282,12 @@ key (or menu-item)"))
1282 file)) 1282 file))
1283 (car elt))) 1283 (car elt)))
1284 1284
1285(defvar menu-bar-buffers-menu-list-buffers-entry nil)
1286
1287(defun menu-bar-update-buffers (&optional force) 1285(defun menu-bar-update-buffers (&optional force)
1288 ;; If user discards the Buffers item, play along. 1286 ;; If user discards the Buffers item, play along.
1289 (and (lookup-key (current-global-map) [menu-bar buffer]) 1287 (and (lookup-key (current-global-map) [menu-bar buffer])
1290 (or force (frame-or-buffer-changed-p)) 1288 (or force (frame-or-buffer-changed-p))
1291 (let ((buffers (buffer-list)) 1289 (let ((buffers (buffer-list))
1292 (frames (frame-list)) 1290 (frames (frame-list))
1293 (maxlen 0)
1294 buffers-menu frames-menu) 1291 buffers-menu frames-menu)
1295 ;; If requested, list only the N most recently selected buffers. 1292 ;; If requested, list only the N most recently selected buffers.
1296 (if (and (integerp buffers-menu-max-size) 1293 (if (and (integerp buffers-menu-max-size)
@@ -1300,102 +1297,82 @@ key (or menu-item)"))
1300 1297
1301 ;; Make the menu of buffers proper. 1298 ;; Make the menu of buffers proper.
1302 (setq buffers-menu 1299 (setq buffers-menu
1303 (cons "Select Buffer" 1300 (let* ((buffer-list
1304 (let* ((buffer-list 1301 (mapcar 'list buffers))
1305 (mapcar 'list buffers)) 1302 (menu-bar-update-buffers-maxbuf 0)
1306 tail 1303 alist)
1307 (menu-bar-update-buffers-maxbuf 0) 1304 ;; Put into each element of buffer-list
1308 alist 1305 ;; the name for actual display,
1309 head) 1306 ;; perhaps truncated in the middle.
1310 ;; Put into each element of buffer-list 1307 (dolist (buf buffer-list)
1311 ;; the name for actual display, 1308 (let ((name (buffer-name (car buf))))
1312 ;; perhaps truncated in the middle. 1309 (setcdr buf
1313 (setq tail buffer-list) 1310 (if (> (length name) 27)
1314 (while tail 1311 (concat (substring name 0 12)
1315 (let ((name (buffer-name (car (car tail))))) 1312 "..."
1316 (setcdr (car tail) 1313 (substring name -12))
1317 (if (> (length name) 27) 1314 name))))
1318 (concat (substring name 0 12) 1315 ;; Compute the maximum length of any name.
1319 "..." 1316 (dolist (buf buffer-list)
1320 (substring name -12)) 1317 (unless (eq ?\ (aref (cdr buf) 0))
1321 name))) 1318 (setq menu-bar-update-buffers-maxbuf
1322 (setq tail (cdr tail))) 1319 (max menu-bar-update-buffers-maxbuf
1323 ;; Compute the maximum length of any name. 1320 (length (cdr buf))))))
1324 (setq tail buffer-list) 1321 ;; Set ALIST to an alist of the form
1325 (while tail 1322 ;; ITEM-STRING . BUFFER
1326 (or (eq ?\ (aref (cdr (car tail)) 0)) 1323 (dolist (buf buffer-list)
1327 (setq menu-bar-update-buffers-maxbuf 1324 (unless (eq ?\ (aref (cdr buf) 0))
1328 (max menu-bar-update-buffers-maxbuf 1325 (push (menu-bar-update-buffers-1 buf) alist)))
1329 (length (cdr (car tail)))))) 1326 ;; Now make the actual list of items, and add
1330 (setq tail (cdr tail))) 1327 ;; some miscellaneous buffer commands to the end.
1331 ;; Set ALIST to an alist of the form 1328 (mapcar (lambda (pair)
1332 ;; ITEM-STRING . BUFFER 1329 ;; This is somewhat risque, to use
1333 (setq tail buffer-list) 1330 ;; the buffer name itself as the event
1334 (while tail 1331 ;; type to define, but it works.
1335 (let ((elt (car tail))) 1332 ;; It would not work to use the buffer
1336 (or (eq ?\ (aref (cdr elt) 0)) 1333 ;; since a buffer as an event has its
1337 (setq alist (cons 1334 ;; own meaning.
1338 (menu-bar-update-buffers-1 elt) 1335 (nconc (list (buffer-name (cdr pair))
1339 alist))) 1336 (car pair)
1340 (and alist (> (length (car (car alist))) maxlen) 1337 (cons nil nil))
1341 (setq maxlen (length (car (car alist)))))) 1338 'menu-bar-select-buffer))
1342 (setq tail (cdr tail))) 1339 (nreverse alist))))
1343 (setq alist (nreverse alist))
1344 ;; Make the menu item for list-buffers
1345 ;; or reuse the one we already have.
1346 ;; The advantage in reusing one
1347 ;; is that it already has the keyboard equivalent
1348 ;; cached, so we save the time to look that up again.
1349 (or menu-bar-buffers-menu-list-buffers-entry
1350 (setq menu-bar-buffers-menu-list-buffers-entry
1351 (cons
1352 'list-buffers
1353 (cons
1354 ""
1355 'list-buffers))))
1356 ;; Update the item string for menu's new width.
1357 (setcar (cdr menu-bar-buffers-menu-list-buffers-entry)
1358 (concat (make-string (max (- (/ maxlen 2) 8) 0)
1359 ?\ )
1360 "List All Buffers"))
1361 ;; Now make the actual list of items,
1362 ;; ending with the list-buffers item.
1363 (nconc (mapcar (lambda (pair)
1364 ;; This is somewhat risque, to use
1365 ;; the buffer name itself as the event
1366 ;; type to define, but it works.
1367 ;; It would not work to use the buffer
1368 ;; since a buffer as an event has its
1369 ;; own meaning.
1370 (nconc (list (buffer-name (cdr pair))
1371 (car pair)
1372 (cons nil nil))
1373 'menu-bar-select-buffer))
1374 alist)
1375 (list menu-bar-buffers-menu-list-buffers-entry)))))
1376
1377 1340
1378 ;; Make a Frames menu if we have more than one frame. 1341 ;; Make a Frames menu if we have more than one frame.
1379 (if (cdr frames) 1342 (when (cdr frames)
1380 (let ((name (concat (make-string (max (- (/ maxlen 2) 3) 0) 1343 (let ((frames-menu
1381 ?\ ) 1344 (cons 'keymap
1382 "Frames")) 1345 (cons "Select Frame"
1383 (frames-menu 1346 (mapcar
1384 (cons 'keymap 1347 (lambda (frame)
1385 (cons "Select Frame" 1348 (nconc
1386 (mapcar 1349 (list (frame-parameter frame 'name)
1387 (lambda (frame) 1350 (frame-parameter frame 'name)
1388 (nconc 1351 (cons nil nil))
1389 (list (frame-parameter frame 'name) 1352 'menu-bar-select-frame))
1390 (frame-parameter frame 'name) 1353 frames)))))
1391 (cons nil nil)) 1354 ;; Put it after the normal buffers
1392 'menu-bar-select-frame)) 1355 (setq buffers-menu
1393 frames))))) 1356 (nconc buffers-menu
1394 ;; Put it underneath the Buffers menu. 1357 `((frames-separator "--")
1395 (setq buffers-menu (cons (cons 'frames (cons name frames-menu)) 1358 (frames menu-item "Frames" ,frames-menu))))))
1396 buffers-menu)))) 1359
1397 (if buffers-menu 1360 ;; Add in some normal commands at the end of the menu
1398 (setq buffers-menu (cons 'keymap buffers-menu))) 1361 (setq buffers-menu
1362 (nconc buffers-menu
1363 '((command-separator "--")
1364 (select-named-buffer
1365 menu-item
1366 "Select Named Buffer..."
1367 switch-to-buffer
1368 :help "Prompt for a buffer name, and select that buffer in the current window")
1369 (list-all-buffers
1370 menu-item
1371 "List All Buffers"
1372 list-buffers
1373 :help "Pop up a window listing all emacs buffers"))))
1374
1375 (setq buffers-menu (cons 'keymap (cons "Select Buffer" buffers-menu)))
1399 (define-key (current-global-map) [menu-bar buffer] 1376 (define-key (current-global-map) [menu-bar buffer]
1400 (cons "Buffers" buffers-menu))))) 1377 (cons "Buffers" buffers-menu)))))
1401 1378