Change: (ts) Accept ts structs

This commit is contained in:
Adam Porter 2019-08-13 16:08:10 -05:00
parent 559764aedd
commit 9f8101779c
2 changed files with 9 additions and 5 deletions

View file

@ -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 ~<=~). + ~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). + ~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~). + ~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-active~ :: Like ~ts~ called with ~:type active~.
+ ~ts-a~ :: Like ~ts~ called with ~:type active~. + ~ts-a~ :: Like ~ts~ called with ~:type active~.
+ ~ts-inactive~ :: Like ~ts~ called with ~:type inactive~. + ~ts-inactive~ :: Like ~ts~ called with ~:type inactive~.

View file

@ -290,9 +290,13 @@ Replaces bare strings with (regexp) selectors, and appropriate
(setq from on (setq from on
to on)) to on))
(when from (when from
(setq from (ts-parse-fill 'begin from))) (setq from (cl-typecase from
(string (ts-parse-fill 'begin from))
(ts from))))
(when to (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' ;; NOTE: The macro must expand to the actual `org-ql--predicate-ts'
;; function, not another `ts'. ;; function, not another `ts'.
`(org-ql--predicate-ts :from ,from :to ,to `(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. If ON, return non-nil if entry has a timestamp on date ON.
FROM, TO, and ON should be strings parseable by FROM, TO, and ON should be either `ts' structs, or strings
`parse-time-string' but may omit the time value. parseable by `parse-time-string' which may omit the time value.
TYPE may be `active' to match active timestamps, `inactive' to TYPE may be `active' to match active timestamps, `inactive' to
match inactive ones, or `both' / nil to match both types." match inactive ones, or `both' / nil to match both types."