How can I restrict the which-func-mode
and the header bar to python-mode
buffers only?
I like to use which-func-mode
in the headline
for Python files/buffers only.
In my current config it works that the mode is activated only if a python-mode
buffer comes up.
But the problem is that after that the which-func-mode
and the headline
is shown in all buffers.
;; =========
;; Which Function Mode
;; =========
(use-package which-func
:config
;; replace nothing found symbol "???"
(setq which-func-unknown "∅")
;; add to headline
(setq-default header-line-format
'((which-func-mode ("" which-func-format " "))))
;; remove from modeline
(setq mode-line-misc-info
(delete '(which-function-mode (which-func-mode
("" which-func-format " ")))
mode-line-misc-info))
)
;; ==========
;; Python
;; ==========
; pip3 install python-lsp-server
(use-package eglot)
(use-package python-mode
:ensure nil ; in-build!
:hook
(python-mode . eglot-ensure)
(python-mode . which-func-mode)
:custom
(python-shell-interpreter "python3")
)
I also tried that solution. But here is the same problem.
(python-mode . which-func-mode)
from your config, btw. You don't want to be calling a global mode every time you open a python file. Just call it once.