wWA5RnA4n2P3w2WvfHq · 2022-11-26 15:04
I'm using Emacs 27. I can activate `hs-minor-mode` in each buffer manually via `M-x hs-minor-mode`. No problem here.
But I want to have that mode for python mode only. And that doesn't work. I got no error but when I try to fold python code I got the regular message that I have to "Enable one of the following modes...".
This is the python part of my `init.el` where I use the `:init` part.
```
(use-package python
:ensure nil ; in-build!
:init
(add-hook 'python-mode-hook 'hs-minor-mode)
:hook
(python-mode . eglot-ensure)
:custom
(python-shell-interpreter "python3")
)
```
I also tried it that way using the `:hook` part.
```
(use-package python
:ensure nil ; in-build!
:hook
(python-mode . eglot-ensure)
(python-mode . hs-minor-mode)
:custom
(python-shell-interpreter "python3")
)
```
Illiamen · 2022-11-26 15:32
Maybe try `(lambda () (hs-minor-mode 1))` for the hook?
It's possible to enable something in a parent mode's hook and then disable it in a derived mode's hook. Since calling the function without an argument toggles the mode, that could be what's happening.
wWA5RnA4n2P3w2WvfHq · 2022-11-26 16:03
It works now with
```
:hook
(python-mode . hs-minor-mode)
```
Some other package (not python, eglot, ...) where involved here. I fixed it. But I can't really tell you what the problem was. Lisp is still mystic to me. ;)
The involved package was `spell-fu`. I removed its python-hook and now all other packages work again. Don't know whats going on.
doolio_ · 2022-11-26 16:18
It makes more sense to me to include these hooks to python-mode in a use-package form for hs-mode and eglot respectively. That is the minor mode or functions you are enabling don't belong to python-mode.