summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--init.el9
-rw-r--r--lisp/+hideshow.el44
2 files changed, 53 insertions, 0 deletions
diff --git a/init.el b/init.el index cc663e4..961e90a 100644 --- a/init.el +++ b/init.el
@@ -247,6 +247,15 @@
247 "M-n" nil 247 "M-n" nil
248 "M-p" nil)) 248 "M-p" nil))
249 249
250(setup hideshow
251 (:also-load +hideshow)
252 (:with-mode hs-minor-mode
253 (:hook-into prog-mode)
254 (:bind "C-<tab>" #'+hs-cycle
255 "C-S-<tab>" #'+hs-global-cycle
256 ;; but y tho
257 "C-S-<iso-lefttab>" #'+hs-global-cycle)))
258
250(setup ibuffer 259(setup ibuffer
251 (:also-load ibuf-ext) 260 (:also-load ibuf-ext)
252 (:option ibuffer-expert t 261 (:option ibuffer-expert t
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