Fix search logic when jumping to first non-finished checkbox
Also stay put when no open checkbox is found, i.e., do not move to the end of the subtree.
This commit is contained in:
parent
5479efabee
commit
4e25b535ca
|
@ -770,12 +770,20 @@ If there's no such open checkbox, emit a message and stay put."
|
|||
(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"))))
|
||||
(let ((original-point (point)))
|
||||
(widen)
|
||||
(org-back-to-heading 'invisible-ok)
|
||||
(org-narrow-to-subtree)
|
||||
(unless
|
||||
;; Yes, progn is not strictly necessary, but it feels cleaner this way.
|
||||
(or (progn
|
||||
(goto-char (point-min))
|
||||
(re-search-forward " \\[-\\] " nil 'no-error))
|
||||
(progn
|
||||
(goto-char (point-min))
|
||||
(re-search-forward " \\[ \\] " nil 'no-error)))
|
||||
(message "No open checkbox in subtree")
|
||||
(goto-char original-point)))))
|
||||
|
||||
|
||||
;;; Calendar
|
||||
|
|
Loading…
Reference in New Issue