Skip to content

Commit

Permalink
Fix: overwrite function in comparison/expansion lists when added
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-shariff committed Feb 12, 2024
1 parent 04c0a88 commit 9f5f123
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions org-roam-ql.el
Original file line number Diff line number Diff line change
Expand Up @@ -356,25 +356,33 @@ Sets the history as well."
;; *****************************************************************************

;;;###autoload
(defmacro org-roam-ql-defpred (name docstring extraction-function comparison-function)
(defun org-roam-ql-defpred (name docstring extraction-function comparison-function)
"Create a org-roam-ql predicate with the NAME.
DOCSTRING is the docstring of the predicate.
The COMPARISON-FUNCTION is a function that returns non-nil if this
predicate doesn't fail for a given org-roam-node. The first value
passed to this function would be the value from calling the
EXTRACTION-FUNCTION with the respective node, and the remainder of the
arguments from the predicate itself."
`(puthash ,name
(list ,docstring ,extraction-function ,comparison-function)
org-roam-ql--query-comparison-functions))
arguments from the predicate itself.
(defmacro org-roam-ql-defexpansion (name docstring expansion-function)
If any predicate or expansion function with same NAME exists, it will be
overwritten."
(remhash name org-roam-ql--query-expansion-functions)
(puthash name
(list docstring extraction-function comparison-function)
org-roam-ql--query-comparison-functions))

(defun org-roam-ql-defexpansion (name docstring expansion-function)
"Add an EXPANSION-FUNCTION identified by NAME in an org-roam-ql query.
DOCSTRING is the docstring of the predicate.
The EXPANSION-FUNCTION should take the parameters
passed in the query and return values that can be passed to
`org-roam-nodes'"
`(puthash ,name (cons ,docstring ,expansion-function) org-roam-ql--query-expansion-functions))
`org-roam-nodes'
If any predicate or expansion function with same NAME exists, it will be
overwritten."
(remhash name org-roam-ql--query-comparison-functions)
(puthash name (cons docstring expansion-function) org-roam-ql--query-expansion-functions))

(defun org-roam-ql--predicate-s-match (value regexp &optional exact)
"Return non-nil if there is a REGEXP match in VALUE.
Expand Down

0 comments on commit 9f5f123

Please sign in to comment.