0

I'm sorry of r a very basic question. I am trying to load iMenu in GNU Emacs at the initialization. Usually it loads by executing M-x imenu-add-menubar-index. I understand I need to put something into my ~/.emacs file, but everything I tried does not work.

I'm new to GNU Emacs and Lisp, what do I need to put there for the index menu to be generated automatically?

gt6989b
  • 4,125
  • 8
  • 46
  • 64
  • More details on `iMenu` can be found here: http://stackoverflow.com/questions/8943705/gnu-emacs-equivalent-of-func-menu – gt6989b Aug 13 '12 at 20:03

1 Answers1

3

You can have an Imenu "Index" menu bar item available for all buffers that belong to a certain major mode by adding imenu-add-menubar-index to its mode hook. For example,

(add-hook 'c-mode-hook #'imenu-add-menubar-index)      ; c
(add-hook 'python-mode-hook #'imenu-add-menubar-index) ; python
dkim
  • 3,930
  • 1
  • 33
  • 37
  • perhaps you could help me with something i noticed when putting in this change. This worked for python like you mentioned, but my c customization is called via `c-mode-common-hook`, not as `c-mode-hook`, that you mentioned. Why is that? – gt6989b Aug 13 '12 at 21:31
  • 1
    `c-mode-common-hook` is a common hook across many languages (including c, c++, java, and so on), but `c-mode-hook` is specific to the C language. Refer to [CC Hooks](http://www.gnu.org/software/emacs/manual/html_node/ccmode/CC-Hooks.html) in the CC mode manual. – dkim Aug 13 '12 at 21:39