Skip to content

Commit 641dd76

Browse files
committed
tweak(hideshow): additional modes' rules
Signed-off-by: Abdelhak Bougouffa <abougouffa@fedoraproject.org>
1 parent f8dc81b commit 641dd76

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

core/me-builtin.el

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,44 @@ or file path may exist now."
476476

477477
(use-package hideshow
478478
;; Hide/show code blocks, a.k.a. code folding
479-
:hook ((prog-mode conf-mode nxml-mode) . hs-minor-mode))
479+
:hook ((prog-mode conf-mode nxml-mode) . hs-minor-mode)
480+
:custom
481+
(hs-hide-comments-when-hiding-all nil)
482+
:config
483+
;; Add extra modes support, needs functions defined in `me-code-folding'
484+
(unless (assq 't hs-special-modes-alist)
485+
(setq hs-special-modes-alist
486+
(append
487+
'((vimrc-mode "{{{" "}}}" "\"")
488+
(yaml-mode "\\s-*\\_<\\(?:[^:]+\\)\\_>"
489+
""
490+
"#"
491+
+fold-hideshow-forward-block-by-indent-fn nil)
492+
(haml-mode "[#.%]" "\n" "/" +fold-hideshow-haml-forward-sexp-fn nil)
493+
(ruby-mode "class\\|d\\(?:ef\\|o\\)\\|module\\|[[{]"
494+
"end\\|[]}]"
495+
"#\\|=begin"
496+
ruby-forward-sexp)
497+
(matlab-mode "if\\|switch\\|case\\|otherwise\\|while\\|for\\|try\\|catch"
498+
"end"
499+
nil (lambda (_arg) (matlab-forward-sexp)))
500+
(nxml-mode "<!--\\|<[^/>]*[^/]>"
501+
"-->\\|</[^/>]*[^/]>"
502+
"<!--" sgml-skip-tag-forward nil)
503+
(latex-mode
504+
;; LaTeX-find-matching-end needs to be inside the env
505+
("\\\\begin{[a-zA-Z*]+}\\(\\)" 1)
506+
"\\\\end{[a-zA-Z*]+}"
507+
"%"
508+
(lambda (_arg)
509+
;; Don't fold whole document, that's useless
510+
(unless (save-excursion
511+
(search-backward "\\begin{document}"
512+
(line-beginning-position) t))
513+
(LaTeX-find-matching-end)))
514+
nil))
515+
hs-special-modes-alist
516+
'((t))))))
480517

481518
(use-package xref
482519
:straight t

0 commit comments

Comments
 (0)