Add bindings to widen org-buffer on next/previous heading

This commit is contained in:
Case Duckworth 2021-08-26 23:30:43 -05:00
parent 82458ead46
commit e627aec4de
2 changed files with 22 additions and 3 deletions

View File

@ -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."
"<S-return>" 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

View File

@ -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