From 9f8101779cab91fdfe157d82bfd8fbd125527d49 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Tue, 13 Aug 2019 16:08:10 -0500 Subject: [PATCH] Change: (ts) Accept ts structs --- README.org | 2 +- org-ql.el | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.org b/README.org index 2726fdd..60c6beb 100644 --- a/README.org +++ b/README.org @@ -160,7 +160,7 @@ Arguments are listed next to predicate names, where applicable. + ~scheduled (&optional comparator target-date)~ :: Return non-nil if entry's scheduled date compares with ~TARGET-DATE~ using ~COMPARATOR~. ~TARGET-DATE~ should be a string parseable by ~date-to-day~. ~COMPARATOR~ should be a function (like ~<=~). + ~tags (&optional tags)~ :: Return non-nil if current heading has one or more of ~TAGS~ (a list of strings). + ~todo (&optional keywords)~ :: Return non-nil if current heading is a ~TODO~ item. With ~KEYWORDS~, return non-nil if its keyword is one of ~KEYWORDS~ (a list of strings). When called without arguments, only matches non-done tasks (i.e. does not match keywords in ~org-done-keywords~). -+ ~ts (&key from to on type)~ :: Return non-nil if current entry has a timestamp in given period. If no arguments are specified, return non-nil if entry has any timestamp. If ~FROM~, return non-nil if entry has a timestamp on or after ~FROM~. If ~TO~, return non-nil if entry has a timestamp on or before ~TO~. If ~ON~, return non-nil if entry has a timestamp on date ~ON~. ~FROM~, ~TO~, and ~ON~ should be strings parseable by ~parse-time-string~ but may omit the time value. ~TYPE~ may be ~active~ to match active timestamps, ~inactive~ to match inactive ones, or ~both~ / nil to match both types. ++ ~ts (&key from to on type)~ :: Return non-nil if current entry has a timestamp in given period. If no arguments are specified, return non-nil if entry has any timestamp. If ~FROM~, return non-nil if entry has a timestamp on or after ~FROM~. If ~TO~, return non-nil if entry has a timestamp on or before ~TO~. 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. ~TYPE~ may be ~active~ to match active timestamps, ~inactive~ to match inactive ones, or ~both~ / nil to match both types. + ~ts-active~ :: Like ~ts~ called with ~:type active~. + ~ts-a~ :: Like ~ts~ called with ~:type active~. + ~ts-inactive~ :: Like ~ts~ called with ~:type inactive~. diff --git a/org-ql.el b/org-ql.el index 1b0970b..a7757cb 100644 --- a/org-ql.el +++ b/org-ql.el @@ -290,9 +290,13 @@ Replaces bare strings with (regexp) selectors, and appropriate (setq from on to on)) (when from - (setq from (ts-parse-fill 'begin from))) + (setq from (cl-typecase from + (string (ts-parse-fill 'begin from)) + (ts from)))) (when to - (setq to (ts-parse-fill 'end to))) + (setq to (cl-typecase to + (string (ts-parse-fill 'end to)) + (ts to)))) ;; NOTE: The macro must expand to the actual `org-ql--predicate-ts' ;; function, not another `ts'. `(org-ql--predicate-ts :from ,from :to ,to @@ -768,8 +772,8 @@ If TO, return non-nil if entry has a timestamp on or before TO. If ON, return non-nil if entry has a timestamp on date ON. -FROM, TO, and ON should be strings parseable by -`parse-time-string' but may omit the time value. +FROM, TO, and ON should be either `ts' structs, or strings +parseable by `parse-time-string' which may omit the time value. TYPE may be `active' to match active timestamps, `inactive' to match inactive ones, or `both' / nil to match both types."