(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
;; 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)
(when (consp binding)
(define-key-after menu (vector key)
(copy-sequence binding))))
- (lookup-key global-map [menu-bar]))
+ (menu-bar-keymap global-map))
menu)
(defun context-menu-local (menu _click)