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.
This commit is contained in:
Adam Porter 2020-11-14 05:41:37 -06:00
parent 89ff02a150
commit 0365b785cc

View file

@ -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.