0

I want to activate origami folding mode for python only. I do use use-package for loading and configuring my packages.

This is what I tried so far

(use-package origami)

(use-package python
  :ensure nil  ; in-build!
  :hook
  (python-mode . origami-mode)
  :custom
  (python-shell-interpreter "python3")
  )

2 Answers 2

2

This solution work but I am not sure if this is the best solution. I still wonder if :hook should be the first choice and how this should be used.

Anyway it works when "moving" the hook into the :config section.

(use-package python
  :ensure nil  ; in-build!
  :config
  (add-hook 'python-mode-hook 'origami-mode)
  :custom
  (python-shell-interpreter "python3")
  )
1
  • 2
    A working solution beats a "better" non-working solution every time :-)
    – NickD
    Apr 22, 2022 at 11:58
1

[I don't know much about use-package and moreover I have not tested this. Try it if you want and let me know if it works: if it does not, I'll delete this answer.]

From reading the Hooks section in the GitHub README for use-package, I think the usage is that you have to add the hook section in the use-package declaration of the minor mode, not that of the major mode. IOW, you have to modify the use-package declaration of origami in order to add the origami minor mode to python-mode:

(use-package origami
  :hook python-mode
  ...
)
1
  • Your solution looks definitly more the use-package way. It has an effect. But I got an error: File mode specification error: (error Autoloading file /home/user/.emacs.d/elpa/origami-20200331.1019/origami.elc failed to define function origami). But I am able to do M-x origami-mode
    – buhtz
    Apr 22, 2022 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.