Add functions for org
These aren't bound or implemented but they're here in case I want them.
This commit is contained in:
parent
4b1eaab205
commit
0b573c7eba
45
lisp/+org.el
45
lisp/+org.el
|
@ -604,5 +604,50 @@ and POST-PROCESS are passed to `org-export-to-file'."
|
|||
;;; go forward and backward in the tree, ~ cleanly ~
|
||||
;; https://stackoverflow.com/a/25201697/10756297
|
||||
|
||||
(defun +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) (show-children))
|
||||
(outline-next-heading)
|
||||
(unless (and (bolp) (org-on-heading-p))
|
||||
(org-up-heading-safe)
|
||||
(hide-subtree)
|
||||
(user-error "Boundary reached"))
|
||||
(org-overview)
|
||||
(org-reveal t)
|
||||
(org-show-entry)
|
||||
(recenter-top-bottom)
|
||||
(show-children)
|
||||
(recenter-top-bottom 1)))
|
||||
|
||||
(defun +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-on-heading-p))
|
||||
(goto-char pos)
|
||||
(hide-subtree)
|
||||
(user-error "Boundary reached"))
|
||||
(org-overview)
|
||||
(org-reveal t)
|
||||
(org-show-entry)
|
||||
(recenter-top-bottom)
|
||||
(show-children)
|
||||
(recenter-top-bottom 1)))
|
||||
|
||||
;;; Make `org-flag-region' (which folds subtrees) recognize
|
||||
;; [[https://teddit.net/r/orgmode/comments/u3du0v/how_to_make_orgcycle_respect_and_always_show_the/][from u/yantar92]]
|
||||
|
||||
;; (advice-add 'org-flag-region :around #'org-flag-region@unfold-page-breaks)
|
||||
(defun org-flag-region@unfold-page-breaks (oldfun from to flag &optional spec)
|
||||
"ADVICE to unfold all the page-break lines inside a folded region."
|
||||
(funcall oldfun from to flag spec)
|
||||
(when (and flag (not (eq 'visible spec)))
|
||||
(org-with-point-at from
|
||||
(while (re-search-forward "\n\u000c\n" to t)
|
||||
(org-flag-region (match-beginning 0) (match-end 0) t 'visible)))))
|
||||
|
||||
(provide '+org)
|
||||
;;; +org.el ends here
|
||||
|
|
Loading…
Reference in New Issue