summaryrefslogtreecommitdiff
path: root/lisp/menu-bar.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@linkov.net>2021-10-21 19:55:24 +0300
committerJuri Linkov <juri@linkov.net>2021-10-21 19:55:24 +0300
commit1cdb4d2077c4e402bf2b2991e8395f0ccdedd1d1 (patch)
tree3e8415c29852089dbe3ad55bfd951a762896f4a0 /lisp/menu-bar.el
parent0545c70c168d2cc3f4fa794312b23f2616f67327 (diff)
downloademacs-1cdb4d2077c4e402bf2b2991e8395f0ccdedd1d1.tar.gz
* lisp/menu-bar.el (menu-bar-keymap): Add optional arg KEYMAP (bug#50067).
* lisp/mouse.el (context-menu-global): Use 'menu-bar-keymap' with its arg KEYMAP set to 'global-map'.
Diffstat (limited to 'lisp/menu-bar.el')
-rw-r--r--lisp/menu-bar.el9
1 files changed, 6 insertions, 3 deletions
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 1cc126b5017..f19dc9e7c97 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -2696,10 +2696,13 @@ This command is to be used when you click the mouse in the menubar."
(cdr menu-bar-item-cons)
0))))
-(defun menu-bar-keymap ()
+(defun menu-bar-keymap (&optional keymap)
"Return the current menu-bar keymap.
+The ordering of the return value respects `menu-bar-final-items'.
-The ordering of the return value respects `menu-bar-final-items'."
+It's possible to use the KEYMAP argument to override the default keymap
+that is the currently active maps. For example, the argument KEYMAP
+could provide `global-map' where items are limited to the global map only."
(let ((menu-bar '())
(menu-end '()))
(map-keymap
@@ -2712,7 +2715,7 @@ The ordering of the return value respects `menu-bar-final-items'."
;; sorting.
(push (cons pos menu-item) menu-end)
(push menu-item menu-bar))))
- (lookup-key (menu-bar-current-active-maps) [menu-bar]))
+ (lookup-key (or keymap (menu-bar-current-active-maps)) [menu-bar]))
`(keymap ,@(nreverse menu-bar)
,@(mapcar #'cdr (sort menu-end
(lambda (a b)