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 --- init.el | 8 +++++--- lisp/acdw-org.el | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/init.el b/init.el index 079e586..587ffdf 100644 --- a/init.el +++ b/init.el @@ -1570,8 +1570,8 @@ successive invocations." ((string-suffix-p "~" pattern) `(orderless-flex . ,(substring pattern 0 -1)))))) -(setup (:straight org) - (:straight org-contrib) +(setup (:straight org + org-contrib) (require 'acdw-org) ; so I don't clutter up init.el (:option org-adapt-indentation nil @@ -1612,7 +1612,9 @@ successive invocations." "" acdw-org/org-table-copy-down "M-SPC M-SPC" insert-zero-width-space "C-c C-l" org-insert-link-dwim - "M-w" acdw/copy-region-plain) + "M-w" acdw/copy-region-plain + "C-c C-n" acdw/org-next-heading-widen + "C-c C-p" acdw/org-previous-heading-widen) (with-eval-after-load 'org-export (add-to-list 'org-export-filter-final-output-functions 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