org-agenda-get-scheduled: Fix wrong matches when WITH-HOUR is non-nil

* lisp/org-agenda.el (org-agenda-get-scheduled): Do not rely on regex
match to judge that current headline is scheduled with time when
WITH-HOUR argument is non-nil.  Limit regexp search when looking for
scheduled timestamp in current headline and intentionally signal
search error if something went wrong (headline without scheduled
timestamp in planning line must not be encountered at this point in
the code).

This commit continues 77a9932b0 and 82197761.
This commit is contained in:
Ihor Radchenko 2021-11-25 18:15:22 +08:00
parent b3cc2f793b
commit 08e595f312
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 14 additions and 2 deletions

View File

@ -6398,7 +6398,14 @@ scheduled items with an hour specification like [h]h:mm."
(if (org-element--cache-active-p)
(org-element-cache-map
(lambda (el)
(when (org-element-property :scheduled el)
(when (and (org-element-property :scheduled el)
(or (not with-hour)
(org-element-property
:hour-start
(org-element-property :scheduled el))
(org-element-property
:hour-end
(org-element-property :scheduled el))))
(goto-char (org-element-property :contents-begin el))
(catch :skip
(org-agenda-skip el)
@ -6408,7 +6415,12 @@ scheduled items with an hour specification like [h]h:mm."
1 -1))
(pos (save-excursion
(goto-char (org-element-property :contents-begin el))
(re-search-forward regexp nil t)
;; We intentionally leave NOERROR
;; argument in `re-search-forward' nil. If
;; the search fails here, something went
;; wrong and we are looking at
;; non-matching headline.
(re-search-forward regexp (line-end-position))
(1- (match-beginning 1))))
(todo-state (org-element-property :todo-keyword el))
(donep (eq 'done (org-element-property :todo-type el)))