Skip to content

Commit 0bba880

Browse files
committed
org-ql-defpred-alias: Simplified custom predicates
1 parent 87b3d0b commit 0bba880

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

org-ql.el

+21
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,27 @@ It would be expanded to:
11321132
(org-ql--define-query-preamble-fn (reverse org-ql-predicates))
11331133
(org-ql--def-query-string-to-sexp-fn (reverse org-ql-predicates))))))
11341134

1135+
(defmacro org-ql-defpred-alias (name args docstring query)
1136+
"Define an `org-ql' predicate alias to complex `org-ql' query.
1137+
NAME may be a symbol or a list of symbols: if a list, the first
1138+
is used as NAME and the rest are aliases.
1139+
1140+
ARGS is a `cl-defun'-style argument list. DOCSTRING is the
1141+
function's docstring.
1142+
1143+
QUERY is a valid `org-ql' query."
1144+
(declare (debug ([&or symbolp listp] listp stringp
1145+
&rest (sexp query)))
1146+
(indent defun))
1147+
`(org-ql-defpred ,name ,args
1148+
,docstring
1149+
:normalizers ((`(,predicate-names)
1150+
(rec ',query)))
1151+
:preambles ((`(,predicate-names)
1152+
(rec ',query)))
1153+
:body
1154+
,query))
1155+
11351156
(defmacro org-ql--from-to-on ()
11361157
"For internal use.
11371158
Expands into a form that processes arguments to timestamp-related

0 commit comments

Comments
 (0)