diff options
| author | Richard M. Stallman | 1995-04-09 07:32:17 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-04-09 07:32:17 +0000 |
| commit | 06ff75391c26ea0de13329717472acfc352c72d8 (patch) | |
| tree | ed7ca9912460194b477c09f55948faba0d75c7e3 | |
| parent | d133d8353a50d817e7a52678f446b6a23d0b89ea (diff) | |
| download | emacs-06ff75391c26ea0de13329717472acfc352c72d8.tar.gz emacs-06ff75391c26ea0de13329717472acfc352c72d8.zip | |
(menu-bar-update-buffers): Reuse the entry for
list-buffers rather than making a new one each time.
| -rw-r--r-- | lisp/menu-bar.el | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 1bb226f7a8c..693cba220fd 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el | |||
| @@ -429,6 +429,8 @@ A large number or nil slows down menu responsiveness.") | |||
| 429 | file)) | 429 | file)) |
| 430 | (car elt))) | 430 | (car elt))) |
| 431 | 431 | ||
| 432 | (defvar menu-bar-buffers-menu-list-buffers-entry nil) | ||
| 433 | |||
| 432 | (defun menu-bar-update-buffers () | 434 | (defun menu-bar-update-buffers () |
| 433 | ;; If user discards the Buffers item, play along. | 435 | ;; If user discards the Buffers item, play along. |
| 434 | (and (lookup-key (current-global-map) [menu-bar buffer]) | 436 | (and (lookup-key (current-global-map) [menu-bar buffer]) |
| @@ -486,6 +488,25 @@ A large number or nil slows down menu responsiveness.") | |||
| 486 | (setq maxlen (length (car (car alist)))))) | 488 | (setq maxlen (length (car (car alist)))))) |
| 487 | (setq tail (cdr tail))) | 489 | (setq tail (cdr tail))) |
| 488 | (setq alist (nreverse alist)) | 490 | (setq alist (nreverse alist)) |
| 491 | ;; Make the menu item for list-buffers | ||
| 492 | ;; or reuse the one we already have. | ||
| 493 | ;; The advantage in reusing one | ||
| 494 | ;; is that it already has the keyboard equivalent | ||
| 495 | ;; cached, so we save the time to look that up again. | ||
| 496 | (or menu-bar-buffers-menu-list-buffers-entry | ||
| 497 | (setq menu-bar-buffers-menu-list-buffers-entry | ||
| 498 | (cons | ||
| 499 | 'list-buffers | ||
| 500 | (cons | ||
| 501 | "" | ||
| 502 | 'list-buffers)))) | ||
| 503 | ;; Update the item string for menu's new width. | ||
| 504 | (setcar (cdr menu-bar-buffers-menu-list-buffers-entry) | ||
| 505 | (concat (make-string (max (- (/ maxlen 2) 8) 0) | ||
| 506 | ?\ ) | ||
| 507 | "List All Buffers")) | ||
| 508 | ;; Now make the actual list of items, | ||
| 509 | ;; ending with the list-buffers item. | ||
| 489 | (nconc (mapcar '(lambda (pair) | 510 | (nconc (mapcar '(lambda (pair) |
| 490 | ;; This is somewhat risque, to use | 511 | ;; This is somewhat risque, to use |
| 491 | ;; the buffer name itself as the event | 512 | ;; the buffer name itself as the event |
| @@ -498,14 +519,7 @@ A large number or nil slows down menu responsiveness.") | |||
| 498 | (cons nil nil)) | 519 | (cons nil nil)) |
| 499 | 'menu-bar-select-buffer)) | 520 | 'menu-bar-select-buffer)) |
| 500 | alist) | 521 | alist) |
| 501 | (list | 522 | (list menu-bar-buffers-menu-list-buffers-entry))))) |
| 502 | (cons | ||
| 503 | 'list-buffers | ||
| 504 | (cons | ||
| 505 | (concat (make-string (max (- (/ maxlen 2) 8) 0) | ||
| 506 | ?\ ) | ||
| 507 | "List All Buffers") | ||
| 508 | 'list-buffers))))))) | ||
| 509 | 523 | ||
| 510 | 524 | ||
| 511 | ;; Make a Frames menu if we have more than one frame. | 525 | ;; Make a Frames menu if we have more than one frame. |