]> code.delx.au - gnu-emacs-elpa/blobdiff - validate.el
Add validate-mark-safe-local
[gnu-emacs-elpa] / validate.el
index 1ded67b0dd49d6d12572a1edcc1d54130ef7e1d6..9eebe9a36e94cf7c6f61d1b60eb1f46bed1cd503 100644 (file)
@@ -175,5 +175,12 @@ with `validate-value'. NOERROR is passed to `validate-value'."
       (if noerror val
         (error "Variable `%s' has no custom-type." symbol)))))
 
+;;;###autoload
+(defun validate-mark-safe-local (symbol)
+  "Mark SYMBOL as a safe local if its custom type is obeyed."
+  (put symbol 'safe-local-variable
+       (lambda (val)
+         (validate-value val (custom-variable-type symbol) 'noerror))))
+
 (provide 'validate)
 ;;; validate.el ends here