From d0c3472de69d1e1dd3d1b2041b38d23005208156 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 20 Dec 2020 08:51:39 -0600 Subject: [PATCH] WIP --- org-ql.el | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/org-ql.el b/org-ql.el index c57cb07..9b94a05 100644 --- a/org-ql.el +++ b/org-ql.el @@ -1772,13 +1772,27 @@ If ON, return non-nil if entry has a timestamp on date ON. FROM, TO, and ON should be either `ts' structs, or strings parseable by `parse-time-string' which may omit the time value." - :normalizers ((`(,predicate-names ,(and num-days (pred numberp))) - (let ((to (->> (ts-now) - (ts-adjust 'day num-days) - (ts-apply :hour 23 :minute 59 :second 59)))) - `(planning :to ,to)))) - :preambles ((`(,predicate-names . ,_) - (list :regexp org-ql-planning-regexp :query query))) + :normalizers + ((`(,predicate-names ,(and num-days (pred numberp))) + (let ((to (->> (ts-now) + (ts-adjust 'day num-days) + (ts-apply :hour 23 :minute 59 :second 59)))) + `(planning :to ,to)))) + :preambles + ((`(,predicate-names . ,(and rest (guard (or (plist-get rest :from) + (plist-get rest :to) + (plist-get rest :on))))) + ;; Use date-optimized timestamp regexp. + (-let (((&plist :from :to :on :type) rest)) + (org-ql--from-to-on) + (list :regexp (-let* ((from (or from (ts-adjust 'day (- org-ql-ts-days-from-default) (ts-now)))) + (to (or to (ts-adjust 'day org-ql-ts-days-to-default (ts-now)))) + (ts-regexp (org-ql--ts-range-to-regexp from to))) + (rx-to-string `(seq bow (0+ blank) (or "CLOSED" "DEADLINE" "SCHEDULED") ":" + (1+ blank) (regexp ,ts-regexp)))) + :query query))) + (`(,predicate-names . ,_) + (list :regexp org-ql-planning-regexp :query query))) :body (org-ql--predicate-ts :from from :to to :regexp org-ql-planning-regexp :match-group 1 :limit (line-end-position 2))) @@ -1809,6 +1823,7 @@ parseable by `parse-time-string' which may omit the time value." ((`(,predicate-names . ,(and rest (guard (or (plist-get rest :from) (plist-get rest :to) (plist-get rest :on))))) + ;; Use date-optimized timestamp regexp. (-let (((&plist :from :to :on :type) rest)) (org-ql--from-to-on) (list :regexp (-let* ((from (or from (ts-adjust 'day (- org-ql-ts-days-from-default) (ts-now)))) @@ -1859,6 +1874,7 @@ of the line after the heading." ((`(,predicate-names . ,(and rest (guard (or (plist-get rest :from) (plist-get rest :to) (plist-get rest :on))))) + ;; Use date-optimized timestamp regexp. (-let (((&plist :from :to :on :type) rest)) (org-ql--from-to-on) (list :regexp (-let* ((from (or from (ts-adjust 'day (- org-ql-ts-days-from-default) (ts-now))))