]> code.delx.au - gnu-emacs-elpa/commitdiff
Don't try to validate undefined vars
authorArtur Malabarba <bruce.connor.am@gmail.com>
Tue, 10 May 2016 17:05:33 +0000 (14:05 -0300)
committerArtur Malabarba <bruce.connor.am@gmail.com>
Tue, 10 May 2016 17:23:07 +0000 (14:23 -0300)
validate.el

index 2d66a2785026f94ecaffed3675a1f1a4d5d860e0..286835e5b1a381babeaaa14058998582d38e2642 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Artur Malabarba <emacs@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