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)
|
(unless (derived-mode-p 'org-mode)
|
||||||
(user-error "Not in Org buffer, exiting"))
|
(user-error "Not in Org buffer, exiting"))
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(widen)
|
(let ((original-point (point)))
|
||||||
(org-back-to-heading 'invisible-ok)
|
(widen)
|
||||||
(org-narrow-to-subtree)
|
(org-back-to-heading 'invisible-ok)
|
||||||
(unless (or (re-search-forward "\\[-\\]" nil 'no-error)
|
(org-narrow-to-subtree)
|
||||||
(re-search-forward "\\[ \\]" nil 'no-error))
|
(unless
|
||||||
(message "No open checkbox in subtree"))))
|
;; 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
|
;;; Calendar
|
||||||
|
|
Loading…
Reference in New Issue