branch: master
commit 7371d05adf4e86f8c6c507d6a8177abac1680d06
Author: Artur Malabarba <bruce.connor...@gmail.com>
Commit: Artur Malabarba <bruce.connor...@gmail.com>

    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 2d66a27..286835e 100644
--- a/validate.el
+++ b/validate.el
@@ -5,7 +5,7 @@
 ;; Author: Artur Malabarba <em...@endlessparentheses.com>
 ;; 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

Reply via email to