Function: imenu-add-to-menubar
imenu-add-to-menubar is an autoloaded, interactive and byte-compiled
function defined in imenu.el.gz.
Signature
(imenu-add-to-menubar NAME)
Documentation
Add an imenu entry to the menu bar for the current buffer.
NAME is a string used to name the menu bar item.
See the command imenu for more information.
Probably introduced at or before Emacs version 19.31.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/imenu.el.gz
;;;###autoload
(defun imenu-add-to-menubar (name)
"Add an `imenu' entry to the menu bar for the current buffer.
NAME is a string used to name the menu bar item.
See the command `imenu' for more information."
(interactive "sImenu menu item name: ")
(if (or (and imenu-prev-index-position-function
imenu-extract-index-name-function)
imenu-generic-expression
(not (eq imenu-create-index-function
'imenu-default-create-index-function)))
(unless (and (current-local-map)
(keymapp (lookup-key (current-local-map) [menu-bar index])))
(let ((newmap (make-sparse-keymap)))
(set-keymap-parent newmap (current-local-map))
(setq imenu--last-menubar-index-alist nil)
(setq imenu--menubar-keymap (make-sparse-keymap "Imenu"))
(define-key newmap [menu-bar index]
`(menu-item ,name ,imenu--menubar-keymap))
(use-local-map newmap)
(add-hook 'menu-bar-update-hook 'imenu-update-menubar)))
(imenu-unavailable-error "The mode `%s' does not support Imenu"
(format-mode-line mode-name))))