This commit is contained in:
Adam Porter 2020-11-22 14:24:07 -06:00
parent b448be874a
commit 18b123a782

View file

@ -994,18 +994,16 @@ It would be expanded to:
(preambles (cl-sublis (list (cons 'predicate-names (cons 'or (--map (list 'quote it) predicate-names))))
preambles)))
`(cl-eval-when (compile load eval)
;; When compiling, the predicate must be added to `org-ql-predicates' before `org-ql--def-query-string-to-sexp-fn'
;; is called to define `org-ql--query-string-to-sexp'. Otherwise, `org-ql--query-string-to-sexp' seems to work properly
;; when interpreted but not always when the file is byte-compiled.
(cl-defun ,fn-name ,args ,docstring ,body)
(setf (map-elt org-ql-predicates ',predicate-name)
`(:name ,',name :aliases ,',aliases :fn ,',fn-name :docstring ,,docstring :args ,',args
:normalizers ,',normalizers :preambles ,',preambles))
(unless org-ql-defpred-defer
;; Reversing preserves the order in which predicates were defined.
(org-ql--define-normalize-query (reverse org-ql-predicates))
;; NOTE: Reversing is important!
(org-ql--define-preamble-fn (reverse org-ql-predicates))
(org-ql--def-query-string-to-sexp-fn))
(cl-defun ,fn-name ,args ,docstring ,body))))
;; FIXME: Pass an argument to `org-ql--def-query-string-to-sexp-fn' too.
(org-ql--def-query-string-to-sexp-fn)))))
;;;;;; Predicates