Change: Handle sort argument in org-ql--query
Rather than in the macro. Trying to consolidate.
This commit is contained in:
parent
9cce826bfe
commit
14351e617d
1 changed files with 13 additions and 17 deletions
30
org-ql.el
30
org-ql.el
|
|
@ -54,18 +54,7 @@ buffer."
|
||||||
,pred-body)))
|
,pred-body)))
|
||||||
:action-fn ,action-fn
|
:action-fn ,action-fn
|
||||||
:narrow ,narrow
|
:narrow ,narrow
|
||||||
:sort ,(pcase sort
|
:sort ',sort))
|
||||||
(`(function ,_)
|
|
||||||
;; Custom sort function
|
|
||||||
sort)
|
|
||||||
((guard (and sort
|
|
||||||
(cl-loop for elem in sort
|
|
||||||
always (memq elem '(date deadline scheduled todo priority)))))
|
|
||||||
;; Default sorting functions
|
|
||||||
(list 'quote sort))
|
|
||||||
(_
|
|
||||||
;; Other expression to evaluate
|
|
||||||
sort))))
|
|
||||||
|
|
||||||
(defmacro org-ql--fmap (fns &rest body)
|
(defmacro org-ql--fmap (fns &rest body)
|
||||||
(declare (indent defun) (debug (listp body)))
|
(declare (indent defun) (debug (listp body)))
|
||||||
|
|
@ -97,11 +86,18 @@ buffer."
|
||||||
(mapcar action-fn
|
(mapcar action-fn
|
||||||
(org-ql--filter-buffer :pred pred :narrow narrow)))
|
(org-ql--filter-buffer :pred pred :narrow narrow)))
|
||||||
buffers-or-files))))
|
buffers-or-files))))
|
||||||
(cl-typecase sort
|
(pcase sort
|
||||||
(list (org-ql--sort-by items sort))
|
(`nil items)
|
||||||
(function (funcall sort items))
|
(`(function ,_)
|
||||||
(null items)
|
;; Custom sort function
|
||||||
(t (user-error "SORT must be a function or a list of methods (see documentation)")))))
|
(funcall sort items))
|
||||||
|
((guard (and sort
|
||||||
|
(setq sort (-list sort))
|
||||||
|
(cl-loop for elem in sort
|
||||||
|
always (memq elem '(date deadline scheduled todo priority)))))
|
||||||
|
;; Default sorting functions
|
||||||
|
(org-ql--sort-by items sort))
|
||||||
|
(_ (user-error "SORT must be either a function, or one or a list of the defined sorting methods (see documentation)")))))
|
||||||
|
|
||||||
(defun org-ql--sanity-check-form (form)
|
(defun org-ql--sanity-check-form (form)
|
||||||
"Signal an error if any of the forms in BODY do not have their preconditions met.
|
"Signal an error if any of the forms in BODY do not have their preconditions met.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue