summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+hideshow.el44
1 files changed, 44 insertions, 0 deletions
diff --git a/lisp/+hideshow.el b/lisp/+hideshow.el new file mode 100644 index 0000000..e60efb8 --- /dev/null +++ b/lisp/+hideshow.el
@@ -0,0 +1,44 @@
1;;; +hideshow.el -*- lexical-binding: t; -*-
2
3;;; Commentary:
4
5;; initiated by https://karthinks.com/software/simple-folding-with-hideshow/
6
7;;; Code:
8
9(defun +hs-cycle (&optional level)
10 (interactive "p")
11 (let (message-log-max
12 (inhibit-message t))
13 (if (= level 1)
14 (pcase last-command
15 ('+hs-cycle
16 (hs-hide-level 1)
17 (setq this-command 'hs-cycle-children))
18 ('hs-cycle-children
19 ;; TODO: Fix this case. `hs-show-block' needs to be
20 ;; called twice to open all folds of the parent
21 ;; block.
22 (save-excursion (hs-show-block))
23 (hs-show-block)
24 (setq this-command 'hs-cycle-subtree))
25 ('hs-cycle-subtree
26 (hs-hide-block))
27 (_
28 (if (not (hs-already-hidden-p))
29 (hs-hide-block)
30 (hs-hide-level 1)
31 (setq this-command 'hs-cycle-children))))
32 (hs-hide-level level)
33 (setq this-command 'hs-hide-level))))
34
35(defun +hs-global-cycle ()
36 (interactive)
37 (pcase last-command
38 ('+hs-global-cycle
39 (save-excursion (hs-show-all))
40 (setq this-command 'hs-global-show))
41 (_ (hs-hide-all))))
42
43(provide '+hideshow)
44;;; +hideshow.el ends here