From 463d5bce7923a1c039c3132285210b2ae1a7eb07 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 2 Oct 2019 15:42:32 -0500 Subject: [PATCH] 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. --- README.org | 5 +++++ org-ql.el | 21 +++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/README.org b/README.org index af8774b..8e7e667 100644 --- a/README.org +++ b/README.org @@ -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. +** 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 *Fixed* diff --git a/org-ql.el b/org-ql.el index e4feb31..94afdf7 100644 --- a/org-ql.el +++ b/org-ql.el @@ -2,7 +2,7 @@ ;; Author: Adam Porter ;; 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")) ;; 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)) (`(timestamp . ,_) context))) ((_timestamp (&keys :warning-value :warning-unit)) deadline-ts-element) - (ts (ts-parse-org-element deadline-ts-element)) - (ts (pcase warning-unit - ('nil ts) - ((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)) - (from (ts<= from ts)) - (to (ts<= ts to))))))) + (ts (ts-parse-org-element deadline-ts-element))) + (pcase warning-unit + ('nil ;; Deadline has no warning unit: compare with ts passed in. + (cond ((and from to) (ts-in from to ts)) + (from (ts<= from ts)) + (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) ;; The underscore before `on' prevents "unused lexical variable"