(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 (consp item)
+ (when (and (consp item) (consp (cdr item)))
(define-key-after menu (vector (car item))
- (if (consp (cdr item))
- (copy-sequence (cdr item))
- (cdr item)))))
+ (copy-sequence (cdr item)))))
menu)
(defun context-menu-local (menu)
(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 (consp item)
+ (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))
- (if (consp (cdr item))
- (copy-sequence (cdr item))
- (cdr item)))))
+ (copy-sequence (cdr item)))))
menu)
(defun context-menu-minor (menu)
(dolist (mode (minor-mode-key-binding [menu-bar]))
(when (and (consp mode) (symbol-value (car mode)))
(dolist (item (cdr mode))
- (when (consp item)
+ (when (and (consp item) (consp (cdr item)))
(define-key-after menu (vector (car item))
- (if (consp (cdr item))
- (copy-sequence (cdr item))
- (cdr item)))))))
+ (copy-sequence (cdr item)))))))
menu)
(defun context-menu-vc (menu)