I'm looking at the code responsible for spacemacs code folding when origami is enabled. All I see is hs-mode
enabled and keys bound to origami's folding functions.
When I put this in my emacs (not spacemacs) config, the folding doesn't work like it does in spacemacs. The following is what I found from .emacs.d/layers/+spacemacs/spacemacs-editing/packages.el
.
(use-package origami
:defer t
:init
(progn
(origami-global-mode 1)
(define-key evil-normal-state-map "za" 'origami-forward-toggle-node)
(define-key evil-normal-state-map "zc" 'origami-close-node)
(define-key evil-normal-state-map "zC" 'origami-close-node-recursively)
...)
...)
When adding this to my emacs config:
1) folding doesn't work when a sexp is on line 1
2) folding works with defun but not use-package or other functions
I want to find the specific parser spacemacs uses to define folds so that I can replicate it in my own emacs. But I don't understand how the folding is working.
For example, it's confusing to me that when I check the binding of za
for example with describe-key
, I see the key is bound to evil-toggle-fold
rather than origami-toggle-fold
which is what I would expect.
Since describe-key
shows that za
is bound to evil-toggle-fold
, I guess the layer is actually not enabled, and the folding behavior is just plain hs-minor-mode
. You can try turn on hs-minor-mode
and toggle the sexp with C-c @ C-c
.