WhichFuncMode (also known as WhichFunctionMode) is a minor mode, that when activated displays the current function name in the mode line. It works under certain major modes, like CcMode or PerlMode. To activate it, type
M-x which-function-mode RET
or enter the following piece of elisp into your `.emacs` file to make it permanent :
M-x imenu RET *Rescan* RET RET
(which-function-mode) (setq mode-line-format (delete (assoc 'which-func-mode mode-line-format) mode-line-format) which-func-header-line-format '(which-func-mode ("" which-func-format))) (defadvice which-func-ff-hook (after header-line activate) (when which-func-mode (setq mode-line-format (delete (assoc 'which-func-mode mode-line-format) mode-line-format) header-line-format which-func-header-line-format)))
(Note: Emacs 24.2.91 seems to put the which-func configuration in
‘mode-line-misc-info’ instead, so you may need to replace
‘mode-line-misc-info’ in the above snippet.)
To get other languages to work with which-func, simple add the name of a programing mode with support for Imenu to
(eval-after-load "which-func" '(add-to-list 'which-func-modes 'java-mode))
To configure a language for which-func mode, you need to configure it for ImenuMode.
An alternative mode that offers similar functionality for several programming languages is SemanticIdleBreadcrumbsMode.
Another alternative mode is cfm. Cfm (display current function or method) will display class-qualified member function names (A::foo), particularly useful for C++ and Java classes that embed member function definitions (that is, without the three-box model).