From 8dae879841dcade01b51c34c1bb6bc75411dac11 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 25 Dec 2022 12:05:52 -0600 Subject: [PATCH] Change: (org-ql-defpred) Ensure aliased predicates have normalizers Would have prevented me from releasing the "c" alias for "category" without a normalizer. --- org-ql.el | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/org-ql.el b/org-ql.el index 7396e5d..7c9d5a9 100644 --- a/org-ql.el +++ b/org-ql.el @@ -1221,6 +1221,13 @@ It would be expanded to: normalizers)) (preambles (cl-sublis (list (cons 'predicate-names (cons 'or (--map (list 'quote it) predicate-names)))) preambles))) + ;; Ensure that a normalizer is defined if aliases are defined. + ;; (This doesn't ensure that the normalizer does what is intended, + ;; but it's at least some safeguard.) + ;; TODO: Add per-predicate test in suite to ensure that aliases + ;; are normalized to the full name. + (when (and aliases (not normalizers)) + (user-error "org-ql-defpred: Aliases defined for predicate `%s' without a normalizer (which must be used to replace aliases with the predicate's full name)" name)) `(progn (cl-defun ,fn-name ,args ,docstring ,body) ;; SOMEDAY: Use `map-elt' here, after map 2.1 can be automatically installed in CI sandbox...