WIP: Add (ts) sorter

Probably will do this separately but it's handy in this branch.
This commit is contained in:
Adam Porter 2023-03-15 03:42:15 -05:00
parent 7b3bb25fd2
commit a441276888

View file

@ -426,7 +426,7 @@ each priority the newest items would appear first."
;; Sort items ;; Sort items
(pcase sort (pcase sort
(`nil items) (`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 ;; Default sorting functions
(org-ql--sort-by items (-list sort))) (org-ql--sort-by items (-list sort)))
;; Sort by user-given comparator. ;; 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))))) (apply-partially #'org-ql--date-type< (intern (concat ":" (symbol-name symbol)))))
;; TODO: Rename `date' to `planning'. `date' should be something else. ;; TODO: Rename `date' to `planning'. `date' should be something else.
('date #'org-ql--date<) ('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<) ('priority #'org-ql--priority<)
('random (lambda (&rest _ignore) ('random (lambda (&rest _ignore)
(= 0 (random 2)))) (= 0 (random 2))))