wWA5RnA4n2P3w2WvfHq · 2022-03-19 14:38
While navigation in Python code I can use `which-function-mode` to show the current function/method in the modeline or (after some more configurations) in the headline also.
It seems that this is a mode is "global" and there is no way to restrict this mode to python buffers only. I don't understand the details but somebody explained it [here on emacs.stackexchange](https://emacs.stackexchange.com/q/71002/1299).
So the question is if there is another package or solution to have something like this (prefered in the headline) but in Python buffers only.
I read about some `lsp-mode` depended solutions. The problem here is that I use `eglot` instead of `lsp-mode` and won't change that.
vifon · 2022-03-19 17:25
A very rudimentary solution you may want to further extend:
(add-hook 'python-mode-hook
(defun which-function-header-line-enable ()
(require 'which-func)
(setq header-line-format
'((:eval (which-function))))))
One thing you will want to add for sure is some throttling so it won't be run too frequently.
Extension_Try_6870 · 2022-03-20 07:34
Maybe this one ? https://www.emacswiki.org/emacs/SemanticIdleBreadcrumbsMode
[deleted] · 2022-03-20 08:54
[deleted]
oantolin · 2022-03-25 19:52
Have you tried using the variable `which-func-modes` to limit the major modes in which `which-function-mode` is active? Like this:
(setq which-func-modes '(python-mode))