Fix: (deadline-warning) Timestamp-local warning periods

When a deadline had its own warning period, it was compared with the
org-deadline-warning-days adjusted timestamp rather than the current
timestamp, which matched deadlines that should not yet be matched.
This commit is contained in:
Adam Porter 2019-10-02 15:42:32 -05:00
parent 527c6f5123
commit 463d5bce79
2 changed files with 16 additions and 10 deletions

View file

@ -441,6 +441,11 @@ Expands into a call to ~org-ql-select~ with the same arguments. For convenience
/Note:/ Breaking changes may be made before version 1.0, but in the event of major changes, attempts at backward compatibility will be made with obsolescence declarations, translation of arguments, etc. Users who need stability guarantees before 1.0 may choose to use tagged stable releases. /Note:/ Breaking changes may be made before version 1.0, but in the event of major changes, attempts at backward compatibility will be made with obsolescence declarations, translation of arguments, etc. Users who need stability guarantees before 1.0 may choose to use tagged stable releases.
** 0.2.2
*Fixed*
+ =(deadline auto)= selector matched entries whose deadlines had a warning period that had not yet been entered (=org-deadline-warning-days= too soon).
** 0.2.1 ** 0.2.1
*Fixed* *Fixed*

View file

@ -2,7 +2,7 @@
;; Author: Adam Porter <adam@alphapapa.net> ;; Author: Adam Porter <adam@alphapapa.net>
;; Url: https://github.com/alphapapa/org-ql ;; Url: https://github.com/alphapapa/org-ql
;; Version: 0.2.1 ;; Version: 0.2.2
;; Package-Requires: ((emacs "26.1") (dash "2.13") (org "9.0") (s "1.12.0") (ts "0.2")) ;; Package-Requires: ((emacs "26.1") (dash "2.13") (org "9.0") (s "1.12.0") (ts "0.2"))
;; Keywords: hypermedia, outlines, Org, agenda ;; Keywords: hypermedia, outlines, Org, agenda
@ -899,15 +899,16 @@ parseable by `parse-time-string' which may omit the time value."
(`(planning ,tss) (plist-get tss :deadline)) (`(planning ,tss) (plist-get tss :deadline))
(`(timestamp . ,_) context))) (`(timestamp . ,_) context)))
((_timestamp (&keys :warning-value :warning-unit)) deadline-ts-element) ((_timestamp (&keys :warning-value :warning-unit)) deadline-ts-element)
(ts (ts-parse-org-element deadline-ts-element)) (ts (ts-parse-org-element deadline-ts-element)))
(ts (pcase warning-unit (pcase warning-unit
('nil ts) ('nil ;; Deadline has no warning unit: compare with ts passed in.
((and unit (or 'year 'month 'day))
(->> ts (ts-adjust unit (* -1 warning-value))))
('week (->> ts (ts-adjust 'day (* -7 warning-value)))))))
(cond ((and from to) (ts-in from to ts)) (cond ((and from to) (ts-in from to ts))
(from (ts<= from ts)) (from (ts<= from ts))
(to (ts<= ts to))))))) (to (ts<= ts to))))
;; Deadline has warning unit: compare with current time (`org-ql--today').
((and unit (or 'year 'month 'day))
(ts<= (->> ts (ts-adjust unit (- warning-value))) org-ql--today))
('week (ts<= (->> ts (ts-adjust 'day (* -7 warning-value))) org-ql--today)))))))
(org-ql--defpred planning (&key from to _on) (org-ql--defpred planning (&key from to _on)
;; The underscore before `on' prevents "unused lexical variable" ;; The underscore before `on' prevents "unused lexical variable"