blob: e60efb89d6ccc91abe8c8ff6dd7c993f35b01398 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
;;; +hideshow.el -*- lexical-binding: t; -*-
;;; Commentary:
;; initiated by https://karthinks.com/software/simple-folding-with-hideshow/
;;; Code:
(defun +hs-cycle (&optional level)
(interactive "p")
(let (message-log-max
(inhibit-message t))
(if (= level 1)
(pcase last-command
('+hs-cycle
(hs-hide-level 1)
(setq this-command 'hs-cycle-children))
('hs-cycle-children
;; TODO: Fix this case. `hs-show-block' needs to be
;; called twice to open all folds of the parent
;; block.
(save-excursion (hs-show-block))
(hs-show-block)
(setq this-command 'hs-cycle-subtree))
('hs-cycle-subtree
(hs-hide-block))
(_
(if (not (hs-already-hidden-p))
(hs-hide-block)
(hs-hide-level 1)
(setq this-command 'hs-cycle-children))))
(hs-hide-level level)
(setq this-command 'hs-hide-level))))
(defun +hs-global-cycle ()
(interactive)
(pcase last-command
('+hs-global-cycle
(save-excursion (hs-show-all))
(setq this-command 'hs-global-show))
(_ (hs-hide-all))))
(provide '+hideshow)
;;; +hideshow.el ends here
|