[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 7371d05 2/3: Don't try to validate undefined vars
From: |
Artur Malabarba |
Subject: |
[elpa] master 7371d05 2/3: Don't try to validate undefined vars |
Date: |
Tue, 10 May 2016 17:23:54 +0000 (UTC) |
branch: master
commit 7371d05adf4e86f8c6c507d6a8177abac1680d06
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>
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 <address@hidden>
;; 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