]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow packages to alter menu entries in the Buffers menu
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 10 May 2022 13:25:06 +0000 (15:25 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 10 May 2022 13:41:27 +0000 (15:41 +0200)
* lisp/menu-bar.el (menu-bar-update-buffers): Use it.
(menu-bar-buffers-menu-command-entries): Put the entries into the
defvar so that packages can modify it (bug#14244).

etc/NEWS
lisp/menu-bar.el

index 13c8aacb2b7d41d5e7c75e071196b41e3e94302f..2557a092a83e54079cdc7848b436ef305e64ff0a 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -256,6 +256,13 @@ startup.  Previously, these functions ignored
 \f
 * Changes in Emacs 29.1
 
+** Menus
+
+---
+*** The entries following the buffers in the "Buffers" menu can now be altered.
+Change the 'menu-bar-buffers-menu-command-entries' variable to alter
+the remaining entries.
+
 ---
 ** 'delete-process' is now a command.
 When called interactively, it will kill the process running in the
index 9a3181afb8d72377957509ae723a53c3466ddd08..488bf05f3ab5d8ada59592249e4a74902f5161d6 100644 (file)
@@ -2320,8 +2320,29 @@ Buffers menu is regenerated."
              (cdr elt)))
          buf)))
 
-;; Used to cache the menu entries for commands in the Buffers menu
-(defvar menu-bar-buffers-menu-command-entries nil)
+(defvar menu-bar-buffers-menu-command-entries
+  (list '(command-separator "--")
+       (list 'next-buffer
+             'menu-item
+             "Next Buffer"
+             'next-buffer
+             :help "Switch to the \"next\" buffer in a cyclic order")
+       (list 'previous-buffer
+             'menu-item
+             "Previous Buffer"
+             'previous-buffer
+             :help "Switch to the \"previous\" buffer in a cyclic order")
+       (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"))
+  "Entries to be included at the end of the \"Buffers\" menu.")
 
 (defvar menu-bar-select-buffer-function 'switch-to-buffer
   "Function to select the buffer chosen from the `Buffers' menu-bar menu.
@@ -2406,35 +2427,7 @@ It must accept a buffer as its only required argument.")
                          `((frames-separator "--")
                            (frames menu-item "Frames" ,frames-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 'next-buffer
-                            'menu-item
-                            "Next Buffer"
-                            'next-buffer
-                            :help "Switch to the \"next\" buffer in a cyclic order")
-                      (list 'previous-buffer
-                            'menu-item
-                            "Previous Buffer"
-                            'previous-buffer
-                            :help "Switch to the \"previous\" buffer in a cyclic order")
-                      (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"
-                            ))))
+        ;; Add in some normal commands at the end of the menu.
         (setq buffers-menu
               (nconc buffers-menu menu-bar-buffers-menu-command-entries))