[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master ec01391ab3 1/2: Allow packages to alter menu entries in the Buffe
From: |
Lars Ingebrigtsen |
Subject: |
master ec01391ab3 1/2: Allow packages to alter menu entries in the Buffers menu |
Date: |
Tue, 10 May 2022 09:41:33 -0400 (EDT) |
branch: master
commit ec01391ab3ecf3c1edb1070c97803e2aa2273367
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Allow packages to alter menu entries in the Buffers menu
* 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 | 7 +++++++
lisp/menu-bar.el | 55 ++++++++++++++++++++++++-------------------------------
2 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 13c8aacb2b..2557a092a8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -256,6 +256,13 @@ startup. Previously, these functions ignored
* 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
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 9a3181afb8..488bf05f3a 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -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))