fix(fold): properly support outline-minor-mode
- Make `+fold/close-all` work for outline-minor-mode.
- Distinguish between `zo` and `zO` for outline-minor-mode alone, by
binding `zO` to a new function `+fold/open-rec`. `zO` will now trigger
`outline-show-subtree` in outline-minor-mode, while `zo` will only
trigger `outline-show-branches`, keeping the subheadings folded. This
matches the behavior in org-mode.
- Fix a bug in `+fold/open-all`, introduced in
7b9d00d661
, that makes it only operate
on vimish-fold folds.
Note that outline-minor-mode is still not enabled by default anywhere.
These changes are only to prevent incorrect behavior for users who
decide to turn it on themselves.
This commit is contained in:
parent
230c82fc95
commit
142f28eb9a
2 changed files with 21 additions and 5 deletions
|
@ -78,6 +78,18 @@ Targets `vimmish-fold', `hideshow', `ts-fold' and `outline' folds."
|
|||
((+fold--hideshow-fold-p) (+fold-from-eol (hs-toggle-hiding)))
|
||||
((+fold--ts-fold-p) (ts-fold-toggle)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +fold/open-rec ()
|
||||
"Recursively open the folded region at point.
|
||||
|
||||
Targets `vimmish-fold', `hideshow', `ts-fold' and `outline' folds."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(cond ((+fold--vimish-fold-p) (vimish-fold-unfold))
|
||||
((+fold--outline-fold-p) (outline-show-subtree))
|
||||
((+fold--hideshow-fold-p) (+fold-from-eol (hs-show-block)))
|
||||
((+fold--ts-fold-p) (ts-fold-open)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +fold/open ()
|
||||
"Open the folded region at point.
|
||||
|
@ -87,7 +99,7 @@ Targets `vimmish-fold', `hideshow', `ts-fold' and `outline' folds."
|
|||
(save-excursion
|
||||
(cond ((+fold--vimish-fold-p) (vimish-fold-unfold))
|
||||
((+fold--outline-fold-p)
|
||||
(outline-show-children)
|
||||
(outline-show-branches)
|
||||
(outline-show-entry))
|
||||
((+fold--hideshow-fold-p) (+fold-from-eol (hs-show-block)))
|
||||
((+fold--ts-fold-p) (ts-fold-open)))))
|
||||
|
@ -111,7 +123,7 @@ Targets `vimmish-fold', `hideshow', `ts-fold' and `outline' folds."
|
|||
(list (if current-prefix-arg (prefix-numeric-value current-prefix-arg))))
|
||||
(cond ((+fold--ts-fold-p)
|
||||
(ts-fold-open-all))
|
||||
((featurep 'vimish-fold)
|
||||
((and (featurep 'vimish-fold) (+fold--vimish-fold-p))
|
||||
(vimish-fold-unfold-all))
|
||||
((save-excursion
|
||||
(+fold--ensure-hideshow-mode)
|
||||
|
@ -138,8 +150,12 @@ Targets `vimmish-fold', `hideshow', `ts-fold' and `outline' folds."
|
|||
(+fold--ensure-hideshow-mode)
|
||||
(hs-life-goes-on
|
||||
(if (integerp level)
|
||||
(hs-hide-level-recursive (1- level) (point-min) (point-max))
|
||||
(hs-hide-all)))))))
|
||||
(progn
|
||||
(outline--show-headings-up-to-level (1+ level))
|
||||
(hs-hide-level-recursive (1- level) (point-min) (point-max)))
|
||||
(hs-hide-all)
|
||||
(when (fboundp 'outline-hide-sublevels)
|
||||
(outline-show-only-headings))))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +fold/next (count)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
[remap evil-toggle-fold] #'+fold/toggle
|
||||
[remap evil-close-fold] #'+fold/close
|
||||
[remap evil-open-fold] #'+fold/open
|
||||
[remap evil-open-fold-rec] #'+fold/open
|
||||
[remap evil-open-fold-rec] #'+fold/open-rec
|
||||
[remap evil-close-folds] #'+fold/close-all
|
||||
[remap evil-open-folds] #'+fold/open-all)
|
||||
(after! evil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue