summaryrefslogtreecommitdiff
path: root/lisp/menu-bar.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1995-04-09 07:32:17 +0000
committerRichard M. Stallman <rms@gnu.org>1995-04-09 07:32:17 +0000
commit49cbabf83297015ab731205478af6ebe47f7bba6 (patch)
tree3376265a55707ef8803152063d3b072dfd694abc /lisp/menu-bar.el
parent5edb909eedf13010e7be6f8c55af20ce1f56cb72 (diff)
downloademacs-49cbabf83297015ab731205478af6ebe47f7bba6.tar.gz
(menu-bar-update-buffers): Reuse the entry for
list-buffers rather than making a new one each time.
Diffstat (limited to 'lisp/menu-bar.el')
-rw-r--r--lisp/menu-bar.el30
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.")
file))
(car elt)))
+(defvar menu-bar-buffers-menu-list-buffers-entry nil)
+
(defun menu-bar-update-buffers ()
;; If user discards the Buffers item, play along.
(and (lookup-key (current-global-map) [menu-bar buffer])
@@ -486,6 +488,25 @@ A large number or nil slows down menu responsiveness.")
(setq maxlen (length (car (car alist))))))
(setq tail (cdr tail)))
(setq alist (nreverse alist))
+ ;; Make the menu item for list-buffers
+ ;; or reuse the one we already have.
+ ;; The advantage in reusing one
+ ;; is that it already has the keyboard equivalent
+ ;; cached, so we save the time to look that up again.
+ (or menu-bar-buffers-menu-list-buffers-entry
+ (setq menu-bar-buffers-menu-list-buffers-entry
+ (cons
+ 'list-buffers
+ (cons
+ ""
+ 'list-buffers))))
+ ;; Update the item string for menu's new width.
+ (setcar (cdr menu-bar-buffers-menu-list-buffers-entry)
+ (concat (make-string (max (- (/ maxlen 2) 8) 0)
+ ?\ )
+ "List All Buffers"))
+ ;; Now make the actual list of items,
+ ;; ending with the list-buffers item.
(nconc (mapcar '(lambda (pair)
;; This is somewhat risque, to use
;; the buffer name itself as the event
@@ -498,14 +519,7 @@ A large number or nil slows down menu responsiveness.")
(cons nil nil))
'menu-bar-select-buffer))
alist)
- (list
- (cons
- 'list-buffers
- (cons
- (concat (make-string (max (- (/ maxlen 2) 8) 0)
- ?\ )
- "List All Buffers")
- 'list-buffers)))))))
+ (list menu-bar-buffers-menu-list-buffers-entry)))))
;; Make a Frames menu if we have more than one frame.