From 0365b785cc075db0012bc919ef101f0b43ba9446 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sat, 14 Nov 2020 05:41:37 -0600 Subject: [PATCH] Fix: (org-ql--defpred) Add to predicates variable when compiling This seems to fix an occasional weird bug encountered when byte-compiling and loading this file. I can't explain why it only happens sometimes, but this seems to fix it, and it stands to reason why it does, so it seems like the right thing to do. --- org-ql.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/org-ql.el b/org-ql.el index f75ce4c..3825ec2 100644 --- a/org-ql.el +++ b/org-ql.el @@ -159,7 +159,11 @@ match." (fn-name (intern (concat "org-ql--predicate-" (symbol-name name)))) (pred-name (intern (symbol-name name)))) `(progn - (push (list :name ',pred-name :aliases ',aliases :fn ',fn-name :docstring ,docstring :args ',args) org-ql-predicates) + (cl-eval-when (compile load eval) + ;; When compiling, the predicate must be added to `org-ql-predicates' before `org-ql--def-plain-query-fn' + ;; is called to define `org-ql--plain-query'. Otherwise, `org-ql--plain-query' seems to work properly + ;; when interpreted but not always when the file is byte-compiled. + (push (list :name ',pred-name :aliases ',aliases :fn ',fn-name :docstring ,docstring :args ',args) org-ql-predicates)) (cl-defun ,fn-name ,args ,docstring ,@body)))) ;; TODO: Mark as obsolete/deprecated.