From 3659f0267f1a70a7141b7d53d8a0696d40247c08 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 4 May 2016 12:26:46 -0300 Subject: [PATCH] Add validate-setq --- validate.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/validate.el b/validate.el index 8408b63c3..7dfe45b01 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.2 +;; Version: 0.3 ;;; Commentary: ;; @@ -182,5 +182,10 @@ with `validate-value'. NOERROR is passed to `validate-value'." (lambda (val) (validate-value val (custom-variable-type symbol) 'noerror)))) +(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)))) + (provide 'validate) ;;; validate.el ends here -- 2.39.2