Skip to content

Commit

Permalink
Add reverse sort functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-shariff committed Aug 26, 2024
1 parent 8b83f44 commit 9071426
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions org-roam-ql.el
Original file line number Diff line number Diff line change
Expand Up @@ -513,16 +513,21 @@ sort-function with the given name already exists, it would be
overwritten."
(puthash function-name sort-function org-roam-ql--sort-functions))

(defun org-roam-ql--sort-function-for-slot (slot-name comparison-function-name)
(defun org-roam-ql--sort-function-for-slot (slot-name comparison-function)
"Add a sort function of SLOT-NAME of org-roam-node.
COMPARISON-FUNCTION-NAME is the symbol of function.
COMPARISON-FUNCTION is the symbol of function.
DOCSTRING is the documentation string to use for the function."
(let ((getter (intern-soft
(format "org-roam-node-%s" slot-name))))
(format "org-roam-node-%s" slot-name)))
(reverse-slot-name (format "%s-reverse" slot-name)))
(org-roam-ql-register-sort-fn
slot-name
`(lambda (node1 node2)
(,comparison-function-name (,getter node1) (,getter node2))))))
(,comparison-function (,getter node1) (,getter node2))))
(org-roam-ql-register-sort-fn
reverse-slot-name
`(lambda (node1 node2)
(,comparison-function (,getter node2) (,getter node1))))))

(defun org-roam-ql--sort-time-less (val1 val2)
"Sort based on time-less-p."
Expand Down

0 comments on commit 9071426

Please sign in to comment.