editor/fold: refactor & fix zm
This fixes an issue where zm wasn't auto-loading hideshow and hs-minor-mode, preventing it from working. Also reveals +fold/* commands to non-evil users (but as of yet, there are still no non-evil keybinds for it).
This commit is contained in:
parent
dd4e265a49
commit
fa664f4e28
4 changed files with 232 additions and 231 deletions
|
@ -18,19 +18,21 @@
|
|||
;; Packages
|
||||
|
||||
(def-package! hideshow ; built-in
|
||||
:defer t
|
||||
:init
|
||||
;; Ensure `hs-minor-mode' is active when triggering these commands
|
||||
(advice-add #'hs-toggle-hiding :before #'+fold-hideshow*ensure-mode)
|
||||
(advice-add #'hs-hide-block :before #'+fold-hideshow*ensure-mode)
|
||||
(advice-add #'hs-hide-level :before #'+fold-hideshow*ensure-mode)
|
||||
(advice-add #'hs-show-all :before #'+fold-hideshow*ensure-mode)
|
||||
(advice-add #'hs-hide-all :before #'+fold-hideshow*ensure-mode)
|
||||
:commands (hs-toggle-hiding hs-hide-block hs-hide-level hs-show-all hs-hide-all)
|
||||
:config
|
||||
(setq hs-hide-comments-when-hiding-all nil
|
||||
;; Nicer code-folding overlays (with fringe indicators)
|
||||
hs-set-up-overlay #'+fold-hideshow-set-up-overlay)
|
||||
|
||||
(defun +fold-hideshow*ensure-mode (&rest _)
|
||||
"Ensure `hs-minor-mode' is enabled."
|
||||
(unless (bound-and-true-p hs-minor-mode)
|
||||
(hs-minor-mode +1)))
|
||||
(advice-add! '(hs-toggle-hiding
|
||||
hs-hide-block hs-hide-level
|
||||
hs-show-all hs-hide-all)
|
||||
:before #'+fold-hideshow*ensure-mode)
|
||||
|
||||
;; extra folding support for more languages
|
||||
(unless (assq 't hs-special-modes-alist)
|
||||
(setq hs-special-modes-alist
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue