"Global submenus."
(run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
(define-key-after menu [separator-global] menu-bar-separator)
- (dolist (item (lookup-key global-map [menu-bar]))
- (when (and (consp item) (consp (cdr item)))
- (define-key-after menu (vector (car item))
- (copy-sequence (cdr item)))))
+ (map-keymap (lambda (key binding)
+ (when (consp binding)
+ (define-key-after menu (vector key)
+ (copy-sequence binding))))
+ (lookup-key global-map [menu-bar]))
menu)
(defun context-menu-local (menu)
"Major mode submenus."
(run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
(define-key-after menu [separator-local] menu-bar-separator)
- (dolist (item (local-key-binding [menu-bar]))
- (when (and (consp item) (consp (cdr item)))
- ;; Fix deep menu created by `imenu-add-to-menubar'.
- (when (eq (car item) 'keymap) (setq item (cadr item)))
- (define-key-after menu (vector (car item))
- (copy-sequence (cdr item)))))
+ (let ((keymap (local-key-binding [menu-bar])))
+ (when keymap
+ (map-keymap (lambda (key binding)
+ (when (consp binding)
+ (define-key-after menu (vector key)
+ (copy-sequence binding))))
+ keymap)))
menu)
(defun context-menu-minor (menu)
(define-key-after menu [separator-minor] menu-bar-separator)
(dolist (mode (minor-mode-key-binding [menu-bar]))
(when (and (consp mode) (symbol-value (car mode)))
- (dolist (item (cdr mode))
- (when (and (consp item) (consp (cdr item)))
- (define-key-after menu (vector (car item))
- (copy-sequence (cdr item)))))))
+ (map-keymap (lambda (key binding)
+ (when (consp binding)
+ (define-key-after menu (vector key)
+ (copy-sequence binding))))
+ (cdr mode))))
menu)
(defun context-menu-vc (menu)