Change: (org-ql-query) Accept comparator function to :sort
This commit is contained in:
parent
88ba3d3933
commit
797798bd08
2 changed files with 13 additions and 6 deletions
|
|
@ -210,7 +210,7 @@ Return items matching ~QUERY~ in ~BUFFERS-OR-FILES~.
|
|||
|
||||
If ~NARROW~ is non-nil, buffers are not widened.
|
||||
|
||||
~SORT~ is either nil, in which case items are not sorted; or one or a list of defined ~org-ql~ sorting methods: ~date~, ~deadline~, ~scheduled~, ~todo~, and ~priority~.
|
||||
~SORT~ is either nil, in which case items are not sorted; or one or a list of defined ~org-ql~ sorting methods (~date~, ~deadline~, ~scheduled~, ~todo~, or ~priority~); or a user-defined comparator function that accepts two items as arguments and returns nil or non-nil.
|
||||
|
||||
**** Macro: ~org-ql~
|
||||
|
||||
|
|
@ -243,6 +243,7 @@ If ~MARKERS~ is non-nil, ~org-agenda-ng--add-markers~ is used to add markers to
|
|||
|
||||
*Changed*
|
||||
+ ~(regexp)~ selector accepts multiple regexps to test.
|
||||
+ The ~:sort~ argument to ~org-ql~, ~org-ql-query~, etc. now also accepts a comparator function by which to sort items.
|
||||
|
||||
*Fixed*
|
||||
+ Handle date ranges in date-based selectors. (Thanks to [[https://github.com/codygman][Cody Goodman]], [[https://github.com/swflint][Samuel W. Flint]], and [[https://github.com/vikasrawal][Vikas Rawal]].)
|
||||
|
|
|
|||
16
org-ql.el
16
org-ql.el
|
|
@ -108,9 +108,11 @@ with point at the beginning of its heading. It is passed to
|
|||
`org-ql-query' as a lambda. By default, `org-element-headline-parser'
|
||||
is called to return an Org element.
|
||||
|
||||
SORT is a user defined sorting function, or an unquoted list of
|
||||
one or more sorting methods, including: `date', `deadline',
|
||||
`scheduled', `todo', and `priority'.
|
||||
SORT is either nil, in which case items are not sorted; or one or
|
||||
a list of predefined `org-ql' sorting methods (`date', `deadline',
|
||||
`scheduled', `todo', or `priority'; or a user-defined comparator
|
||||
function that accepts two items as arguments and returns nil or
|
||||
non-nil.
|
||||
|
||||
If NARROW is non-nil, query will run without widening the
|
||||
buffer (the default is to widen and search the entire buffer).
|
||||
|
|
@ -158,8 +160,10 @@ compatible with Org Agenda code.
|
|||
If NARROW is non-nil, buffers are not widened.
|
||||
|
||||
SORT is either nil, in which case items are not sorted; or one or
|
||||
a list of defined `org-ql' sorting methods: `date', `deadline',
|
||||
`scheduled', `todo', and `priority'."
|
||||
a list of defined `org-ql' sorting methods (`date', `deadline',
|
||||
`scheduled', `todo', or `priority'); or a user-defined comparator
|
||||
function that accepts two items as arguments and returns nil or
|
||||
non-nil."
|
||||
(declare (indent defun))
|
||||
(-let* ((buffers (->> (cl-typecase buffers-or-files
|
||||
(null (list (current-buffer)))
|
||||
|
|
@ -197,6 +201,8 @@ a list of defined `org-ql' sorting methods: `date', `deadline',
|
|||
always (memq elem '(date deadline scheduled todo priority)))))
|
||||
;; Default sorting functions
|
||||
(org-ql--sort-by items sort))
|
||||
;; Sort by user-given comparator.
|
||||
((pred functionp) (sort items sort))
|
||||
(_ (user-error "SORT must be either nil, or one or a list of the defined sorting methods (see documentation)")))))
|
||||
|
||||
(defun org-ql--query-predicate (query)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue