Function: menu-bar-keymap
menu-bar-keymap is a byte-compiled function defined in menu-bar.el.gz.
Signature
(menu-bar-keymap &optional KEYMAP)
Documentation
Return the current menu-bar keymap.
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.
Source Code
;; Defined in /usr/src/emacs/lisp/menu-bar.el.gz
(defun menu-bar-keymap (&optional keymap)
"Return the current menu-bar keymap.
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
(lambda (key binding)
(let ((pos (seq-position menu-bar-final-items key))
(menu-item (cons key binding)))
(if pos
;; If KEY is the name of an item that we want to put
;; last, store it separately with explicit ordering for
;; sorting.
(push (cons pos menu-item) menu-end)
(push menu-item menu-bar))))
(or keymap (lookup-key (menu-bar-current-active-maps) [menu-bar])))
`(keymap ,@(nreverse menu-bar)
,@(mapcar #'cdr (sort menu-end
(lambda (a b)
(< (car a) (car b))))))))