Fix: (deadline-warning) Handle plain timestamp elements
Sometimes org-element-context returns an element like:
(planning (:closed (timestamp (:type inactive ...))
:deadline (timestamp (:type active ...))
:scheduled (timestamp (:type active ...))
:begin 93706 ...))
Other times it returns just:
(timestamp (:type active ...))
Even with point in the same position, immediately after the deadline
timestamp. I don't know why, and it might even be a bug that's been
fixed in newer version of Org.
Anyway, this handles both.
This commit is contained in:
parent
fea39f5c05
commit
027bb89373
1 changed files with 9 additions and 5 deletions
14
org-ql.el
14
org-ql.el
|
|
@ -827,11 +827,15 @@ parseable by `parse-time-string' which may omit the time value."
|
||||||
(forward-line 1)
|
(forward-line 1)
|
||||||
(when (re-search-forward org-deadline-time-regexp (line-end-position) t)
|
(when (re-search-forward org-deadline-time-regexp (line-end-position) t)
|
||||||
(-let* ((context (org-element-context))
|
(-let* ((context (org-element-context))
|
||||||
;; Since we need to handle warning periods, we parse the
|
;; Since we need to handle warning periods, we parse the Org timestamp
|
||||||
;; Org timestamp as an org-element rather than as a string.
|
;; as an org-element rather than as a string. Unfortunately, sometimes
|
||||||
((_planning (_closed _nil _deadline element . _rest)) context)
|
;; `org-element-context' returns a timestamp nested inside a `planning'
|
||||||
((_timestamp (&keys :warning-value :warning-unit)) element)
|
;; element, other times just the timestamp, so we have to handle both.
|
||||||
(ts (ts-parse-org-element element))
|
(deadline-ts-element (pcase context
|
||||||
|
(`(planning ,tss) (plist-get tss :deadline))
|
||||||
|
(`(timestamp . ,_) context)))
|
||||||
|
((_timestamp (&keys :warning-value :warning-unit)) deadline-ts-element)
|
||||||
|
(ts (ts-parse-org-element deadline-ts-element))
|
||||||
(ts (pcase warning-unit
|
(ts (pcase warning-unit
|
||||||
('nil ts)
|
('nil ts)
|
||||||
((and unit (or 'year 'month 'day))
|
((and unit (or 'year 'month 'day))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue