From 8515985057183aa49973fbc6ced7c37c779b2123 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 28 Dec 2021 18:20:24 -0600 Subject: Setup hideshow.el --- lisp/+hideshow.el | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 lisp/+hideshow.el (limited to 'lisp') 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 @@ +;;; +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 -- cgit 1.4.1-21-gabe81