From e627aec4ded8a98b724a6d0aef4a1e54124eeb20 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 26 Aug 2021 23:30:43 -0500 Subject: Add bindings to widen org-buffer on next/previous heading --- lisp/acdw-org.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lisp/acdw-org.el') diff --git a/lisp/acdw-org.el b/lisp/acdw-org.el index 2f798d9..75c5f7a 100644 --- a/lisp/acdw-org.el +++ b/lisp/acdw-org.el @@ -366,6 +366,23 @@ instead of the true count." (t (call-interactively 'org-insert-link))))) + +;;; Next and previous heading, with widening +(defun acdw/org-next-heading-widen (arg) + (interactive "p") + (let ((point-target (if (> arg 0) + (point-max) + (point-min)))) + (unless (or (org-next-visible-heading arg) + (/= (point) point-target)) + (when (buffer-narrowed-p) + (widen) + (org-next-visible-heading arg))))) + +(defun acdw/org-previous-heading-widen (arg) + (interactive "p") + (acdw/org-next-heading (- arg))) + (provide 'acdw-org) ;; acdw-org.el ends here -- cgit 1.4.1-21-gabe81