summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+org.el45
1 files changed, 45 insertions, 0 deletions
diff --git a/lisp/+org.el b/lisp/+org.el index 400172f..84b0288 100644 --- a/lisp/+org.el +++ b/lisp/+org.el
@@ -604,5 +604,50 @@ and POST-PROCESS are passed to `org-export-to-file'."
604;;; go forward and backward in the tree, ~ cleanly ~ 604;;; go forward and backward in the tree, ~ cleanly ~
605;; https://stackoverflow.com/a/25201697/10756297 605;; https://stackoverflow.com/a/25201697/10756297
606 606
607(defun +org-show-next-heading-tidily ()
608 "Show next entry, keeping other entries closed."
609 (interactive)
610 (if (save-excursion (end-of-line) (outline-invisible-p))
611 (progn (org-show-entry) (show-children))
612 (outline-next-heading)
613 (unless (and (bolp) (org-on-heading-p))
614 (org-up-heading-safe)
615 (hide-subtree)
616 (user-error "Boundary reached"))
617 (org-overview)
618 (org-reveal t)
619 (org-show-entry)
620 (recenter-top-bottom)
621 (show-children)
622 (recenter-top-bottom 1)))
623
624(defun +org-show-previous-heading-tidily ()
625 "Show previous entry, keeping other entries closed."
626 (interactive)
627 (let ((pos (point)))
628 (outline-previous-heading)
629 (unless (and (< (point) pos) (bolp) (org-on-heading-p))
630 (goto-char pos)
631 (hide-subtree)
632 (user-error "Boundary reached"))
633 (org-overview)
634 (org-reveal t)
635 (org-show-entry)
636 (recenter-top-bottom)
637 (show-children)
638 (recenter-top-bottom 1)))
639
640;;; Make `org-flag-region' (which folds subtrees) recognize
641;; [[https://teddit.net/r/orgmode/comments/u3du0v/how_to_make_orgcycle_respect_and_always_show_the/][from u/yantar92]]
642
643;; (advice-add 'org-flag-region :around #'org-flag-region@unfold-page-breaks)
644(defun org-flag-region@unfold-page-breaks (oldfun from to flag &optional spec)
645 "ADVICE to unfold all the page-break lines inside a folded region."
646 (funcall oldfun from to flag spec)
647 (when (and flag (not (eq 'visible spec)))
648 (org-with-point-at from
649 (while (re-search-forward "\n\u000c\n" to t)
650 (org-flag-region (match-beginning 0) (match-end 0) t 'visible)))))
651
607(provide '+org) 652(provide '+org)
608;;; +org.el ends here 653;;; +org.el ends here