Change: (org-ql-defpred) Ensure aliased predicates have normalizers

Would have prevented me from releasing the "c" alias for "category"
without a normalizer.
This commit is contained in:
Adam Porter 2022-12-25 12:05:52 -06:00
parent d253b123cf
commit 8dae879841

View file

@ -1221,6 +1221,13 @@ It would be expanded to:
normalizers)) normalizers))
(preambles (cl-sublis (list (cons 'predicate-names (cons 'or (--map (list 'quote it) predicate-names)))) (preambles (cl-sublis (list (cons 'predicate-names (cons 'or (--map (list 'quote it) predicate-names))))
preambles))) 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 `(progn
(cl-defun ,fn-name ,args ,docstring ,body) (cl-defun ,fn-name ,args ,docstring ,body)
;; SOMEDAY: Use `map-elt' here, after map 2.1 can be automatically installed in CI sandbox... ;; SOMEDAY: Use `map-elt' here, after map 2.1 can be automatically installed in CI sandbox...