From a441276888d8e8524e86688a8c7d5f08b9421cac Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 15 Mar 2023 03:42:15 -0500 Subject: [PATCH] WIP: Add (ts) sorter Probably will do this separately but it's handy in this branch. --- org-ql.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/org-ql.el b/org-ql.el index c0f548a..c9f73fb 100644 --- a/org-ql.el +++ b/org-ql.el @@ -426,7 +426,7 @@ each priority the newest items would appear first." ;; Sort items (pcase sort (`nil items) - ((guard (cl-subsetp (-list sort) '(date deadline scheduled closed todo priority random reverse))) + ((guard (cl-subsetp (-list sort) '(date deadline scheduled closed todo priority random reverse ts))) ;; Default sorting functions (org-ql--sort-by items (-list sort))) ;; Sort by user-given comparator. @@ -2407,6 +2407,10 @@ PREDICATES is a list of one or more sorting methods, including: (apply-partially #'org-ql--date-type< (intern (concat ":" (symbol-name symbol))))) ;; TODO: Rename `date' to `planning'. `date' should be something else. ('date #'org-ql--date<) + (`ts (lambda (a b) + (when-let ((a-ts (taxy-org-ql--latest-timestamp-in a)) + (b-ts (taxy-org-ql--latest-timestamp-in b))) + (ts< a-ts b-ts)))) ('priority #'org-ql--priority<) ('random (lambda (&rest _ignore) (= 0 (random 2))))