[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 423a6b2 2/2: Merge commit '06e8bd7d4c31ba5b10cf5c18a13c537
From: |
Artur Malabarba |
Subject: |
[elpa] master 423a6b2 2/2: Merge commit '06e8bd7d4c31ba5b10cf5c18a13c5370045cea71' |
Date: |
Thu, 12 May 2016 13:12:19 +0000 (UTC) |
branch: master
commit 423a6b218804a210486fdb06af44bcc700b1bca4
Merge: 40fd76b 06e8bd7
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>
Merge commit '06e8bd7d4c31ba5b10cf5c18a13c5370045cea71'
---
packages/validate/validate.el | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/packages/validate/validate.el b/packages/validate/validate.el
index 286835e..7ca4b0a 100644
--- a/packages/validate/validate.el
+++ b/packages/validate/validate.el
@@ -5,7 +5,7 @@
;; Author: Artur Malabarba <address@hidden>
;; Keywords: lisp
;; Package-Requires: ((emacs "24.1") (cl-lib "0.5"))
-;; Version: 0.4
+;; Version: 0.5
;;; Commentary:
;;
@@ -188,13 +188,23 @@ with `validate-value'. NOERROR is passed to
`validate-value'."
(lambda (val)
(validate-value val (custom-variable-type symbol) 'noerror))))
-(defmacro validate-setq (symbol value)
+(defmacro validate-setq (&rest svs)
"Like `setq', but throw an error if validation fails.
-VALUE is validated against SYMBOL's custom type."
- `(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)))
+VALUE is validated against SYMBOL's custom type.
+
+\(fn [SYM VAL] ...)"
+ (let ((out))
+ (while svs
+ (let ((symbol (pop svs))
+ (value (if (not svs)
+ (error "`validate-setq' takes an even number of
arguments")
+ (pop svs))))
+ (push `(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))
+ out)))
+ `(progn ,@(reverse out))))
(provide 'validate)
;;; validate.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] master 423a6b2 2/2: Merge commit '06e8bd7d4c31ba5b10cf5c18a13c5370045cea71',
Artur Malabarba <=