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)
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With