From 7371d05adf4e86f8c6c507d6a8177abac1680d06 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Tue, 10 May 2016 14:05:33 -0300 Subject: [PATCH] Don't try to validate undefined vars --- validate.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/validate.el b/validate.el index 2d66a2785..286835e5b 100644 --- a/validate.el +++ b/validate.el @@ -5,7 +5,7 @@ ;; Author: Artur Malabarba ;; Keywords: lisp ;; Package-Requires: ((emacs "24.1") (cl-lib "0.5")) -;; Version: 0.3 +;; Version: 0.4 ;;; Commentary: ;; @@ -191,7 +191,10 @@ with `validate-value'. NOERROR is passed to `validate-value'." (defmacro validate-setq (symbol value) "Like `setq', but throw an error if validation fails. VALUE is validated against SYMBOL's custom type." - `(setq ,symbol (validate-value ,value (custom-variable-type ',symbol)))) + `(if (boundp ',symbol) + (setq ,symbol (validate-value ,value (custom-variable-type ',symbol))) + (user-error "Trying to validate a variable that's not defined yet: `%s'.\nYou need to require the package before validating" + ',symbol))) (provide 'validate) ;;; validate.el ends here -- 2.39.2