Add function to jump to first open checkbox in subtree

Still needs a nice key binding.
This commit is contained in:
Daniel Borchmann 2022-08-28 19:07:51 +02:00
parent 63a03f0038
commit 5479efabee
No known key found for this signature in database
GPG Key ID: 784AA8DF0CCDF625
2 changed files with 49 additions and 30 deletions

View File

@ -766,7 +766,8 @@
db/org-add-link-to-other-item
db/org-add-link-to-current-clock
hydra-org-linking/body
org-dblock-write:db/org-backlinks))
org-dblock-write:db/org-backlinks
db/org-goto-first-open-checkbox-in-subtree))
(use-package org
:pin "gnu"

View File

@ -759,6 +759,24 @@ cache if that's in use."
(when (derived-mode-p 'org-agenda-mode)
(org-agenda-redo)))
(defun db/org-goto-first-open-checkbox-in-subtree ()
"Jump to first open checkbox in the current subtree.
First search for started checkboxes, i.e. [-], and if those are
not found, go to the first open checkbox, i.e. [ ].
If there's no such open checkbox, emit a message and stay put."
(interactive)
(unless (derived-mode-p 'org-mode)
(user-error "Not in Org buffer, exiting"))
(save-restriction
(widen)
(org-back-to-heading 'invisible-ok)
(org-narrow-to-subtree)
(unless (or (re-search-forward "\\[-\\]" nil 'no-error)
(re-search-forward "\\[ \\]" nil 'no-error))
(message "No open checkbox in subtree"))))
;;; Calendar