Skip to content

Commit

Permalink
Fix: (org-ql-select) Properly accept arbitrary sort function
Browse files Browse the repository at this point in the history
Fixes #37.  Thanks to Milan Zamazal (@mz-pdm).
  • Loading branch information
alphapapa committed Aug 26, 2019
1 parent c576813 commit f26052e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ Expands into a call to ~org-ql-select~ with the same arguments. For convenience
+ Don't overwrite bindings in =org-agenda-mode-map=.
+ Don't search buffers without headings, and show a message if the user attempts it.
+ Don't search hidden/special buffers.
+ Properly accept arbitrary sort functions in =org-ql-select=, etc. (Fixes [[https://github.com/alphapapa/org-ql/issues/37][#37]]. Thanks to [[https://github.com/mz-pdm][Milan Zamazal]].)

*Compatibility*
+ Fixes for compatibility with Org 9.2. (Thanks to [[https://github.com/ataias][Ataias Pereira Reis]] and [[https://github.com/dakra][Daniel Kraus]].)
Expand Down
11 changes: 5 additions & 6 deletions org-ql.el
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,14 @@ non-nil."
;; Sort items
(pcase sort
(`nil items)
((guard (and sort
(setq sort (-list sort))
(cl-loop for elem in sort
always (memq elem '(date deadline scheduled todo priority)))))
((or 'date 'deadline 'scheduled 'todo 'priority
(guard (cl-loop for elem in sort
always (memq elem '(date deadline scheduled todo priority)))))
;; Default sorting functions
(org-ql--sort-by items sort))
(org-ql--sort-by items (-list 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)")))))
(_ (user-error "SORT must be either nil, one or a list of the defined sorting methods (see documentation), or a comparison function of two arguments")))))

(cl-defun org-ql-query (&key (select 'element-with-markers) from where narrow order-by)
"Like `org-ql-select', but arguments are named more like a SQL query.
Expand Down

0 comments on commit f26052e

Please sign in to comment.