I am using the folding minor mode in Emacs which I get installed with the following use-package
macro:
(use-package folding
:ensure t)
The above works and ensures that folding
is installed whenever I fire up Emacs. However, when I visit a buffer with the folded marks ( // {{{
and // }}}
), the minor mode is not automatically loaded and I have to load it explicitly with:
M-x folding-mode
I looked up the documentation and saw that for the Folding mode to start automatically when a folded file is loaded you need to do this:
(if (load "folding" 'nomessage 'noerror)
(folding-mode-add-find-file-hook))
However, changing my use-package
macro to the following:
(use-package folding
:ensure t
:config
(if (load "folding" 'nomessage 'noerror)
(folding-mode-add-find-file-hook))
)
… makes no difference. I still have to load folding mode manually with M-x folding-mode
. What gives?
update
Turns out that in addition to the accepted answer, I also had to add an Emacs file variable at the end of the file:
// {{{ folding-mode
// Local Variables:
// folded-file: t
// End:
// }}}
But adding this editor-specific markup in every source file is too much for me. Is there a way to automatically always activate folding-mode
when visiting a buffer?
I have tried
(use-package folding
:ensure t
:config
(folding-mode))
… and:
(use-package folding
:ensure t
:config
(setq 'folding-mode t))
… but none of the above is working.