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:
Henrik Lissner 2019-05-15 16:09:53 -04:00
parent dd4e265a49
commit fa664f4e28
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
4 changed files with 232 additions and 231 deletions

View file

@ -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