Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display function name in status-line

Tags:

emacs

I'd like to have the function name displayed next to the buffer name on the mode-line if the point is inside a function (maybe with some reasonable truncation if necessary).

Is ther a simple way to achieve this? (via imenu? defuns?)

Example: in test.py if my cursor is inside def myfunction, I'd like my mode-line say:

test.py: myfunction

Could be also interesting for org mode (displaying the inside-most header)

like image 405
user673592 Avatar asked Jun 07 '13 13:06

user673592


2 Answers

Which Function Mode should help you :

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 this minor mode : M-x which-function-mode RET

An interesting effect of this mode is by middle-clicking on the current function name : it can narrow the display to the current function.

like image 59
Seki Avatar answered Nov 16 '22 18:11

Seki


OK... I found it: the mode is built in and can be globally activated by:

(which-function-mode 1)

Change colors and add major modes (e.g. org-mode is not enabled by default) with:

M-x customize-group and selecting which-func

like image 24
user673592 Avatar answered Nov 16 '22 18:11

user673592