From 705acb6175c05ff33dd81cfd292e23d6bb225d65 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 7 Oct 2021 18:23:13 -0500 Subject: Hide everything but the current headline in org-mode --- lisp/acdw-org.el | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'lisp') diff --git a/lisp/acdw-org.el b/lisp/acdw-org.el index 05e6409..a1558a2 100644 --- a/lisp/acdw-org.el +++ b/lisp/acdw-org.el @@ -470,6 +470,43 @@ probably abandon it at some point for a better solution (see: (org-previous-visible-heading 1)) (org-narrow-to-subtree)))) + +;;; Hide everything but the current headline +;; https://stackoverflow.com/questions/25161792/ + +(defun acdw-org/show-next-heading-tidily () + "Show next entry, keeping other entries closed." + (interactive) + (if (save-excursion (end-of-line) (outline-invisible-p)) + (progn (org-show-entry) (outline-show-children)) + (outline-next-heading) + (unless (and (bolp) (org-at-heading-p)) + (org-up-heading-safe) + (outline-hide-subtree) + (error "Boundary reached")) + (org-overview) + (org-reveal t) + (org-show-entry) + (recenter-top-bottom) + (outline-show-children) + (recenter-top-bottom))) + +(defun acdw-org/show-previous-heading-tidily () + "Show previous entry, keeping other entries closed." + (interactive) + (let ((pos (point))) + (outline-previous-heading) + (unless (and (< (point) pos) (bolp) (org-at-heading-p)) + (goto-char pos) + (outline-hide-subtree) + (error "Boundary reached")) + (org-overview) + (org-reveal t) + (org-show-entry) + (recenter-top-bottom) + (outline-show-children) + (recenter-top-bottom))) + (provide 'acdw-org) ;;; acdw-org.el ends here -- cgit 1.4.1-21-gabe81