]> code.delx.au - gnu-emacs/commitdiff
(menu-bar-update-buffers): Don't use constant lists for command menu
authorMiles Bader <miles@gnu.org>
Tue, 23 Apr 2002 08:36:35 +0000 (08:36 +0000)
committerMiles Bader <miles@gnu.org>
Tue, 23 Apr 2002 08:36:35 +0000 (08:36 +0000)
entries, since the low-level menu code modifies them.  Cache the
resulting list.
(menu-bar-buffers-menu-command-entries): New variable.

lisp/ChangeLog
lisp/menu-bar.el

index a9c7da1ed7e376e03f2102da929c81fb010a93db..3c2442b9dba17b010dcb2b8040c4fafd51031bce 100644 (file)
@@ -1,5 +1,10 @@
 2002-04-23  Miles Bader  <miles@gnu.org>
 
+       * menu-bar.el (menu-bar-update-buffers): Don't use constant lists
+       for command menu entries, since the low-level menu code modifies
+       them.  Cache the resulting list.
+       (menu-bar-buffers-menu-command-entries): New variable.
+
        * menu-bar.el (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
index e7a6eed98774eeaad1565e450ef54f6151f80889..c5765230f0341d89477c1b1c3b83eb516841873a 100644 (file)
@@ -1282,6 +1282,9 @@ key (or menu-item)"))
           file))
        (car elt)))
 
+;; Used to cache the menu entries for commands in the Buffers menu
+(defvar menu-bar-buffers-menu-command-entries nil)
+
 (defun menu-bar-update-buffers (&optional force)
   ;; If user discards the Buffers item, play along.
   (and (lookup-key (current-global-map) [menu-bar buffer])
@@ -1357,20 +1360,27 @@ key (or menu-item)"))
                          `((frames-separator "--")
                            (frames menu-item "Frames" ,frames-menu))))))
 
-        ;; Add in some normal commands at the end of the menu
+        ;; Add in some normal commands at the end of the menu.  We use
+        ;; the copy cached in `menu-bar-buffers-menu-command-entries'
+        ;; if it's been set already.  Note that we can't use constant
+        ;; lists for the menu-entries, because the low-level menu-code
+        ;; modifies them.
+        (unless menu-bar-buffers-menu-command-entries
+          (setq menu-bar-buffers-menu-command-entries
+                (list '(command-separator "--")
+                      (list 'select-named-buffer
+                            'menu-item
+                            "Select Named Buffer..."
+                            'switch-to-buffer
+                            :help "Prompt for a buffer name, and select that buffer in the current window")
+                      (list 'list-all-buffers
+                            'menu-item
+                            "List All Buffers"
+                            'list-buffers
+                            :help "Pop up a window listing all emacs buffers"
+                            ))))
         (setq buffers-menu
-              (nconc buffers-menu
-                     '((command-separator "--")
-                       (select-named-buffer
-                        menu-item
-                        "Select Named Buffer..."
-                        switch-to-buffer
-                        :help "Prompt for a buffer name, and select that buffer in the current window")
-                       (list-all-buffers
-                        menu-item
-                        "List All Buffers"
-                        list-buffers
-                        :help "Pop up a window listing all emacs buffers"))))
+              (nconc buffers-menu menu-bar-buffers-menu-command-entries))
 
         (setq buffers-menu (cons 'keymap (cons "Select Buffer" buffers-menu)))
         (define-key (current-global-map) [menu-bar buffer]