X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/dfae733bf0cea4988a23ab18f5b0c2a8d16682ca..dbafdb904b48e72620f066a5c7cb0a123fc64baa:/validate.el diff --git a/validate.el b/validate.el index 0482be348..9eebe9a36 100644 --- a/validate.el +++ b/validate.el @@ -7,19 +7,6 @@ ;; Package-Requires: ((emacs "24.1") (cl-lib "0.5")) ;; Version: 0.1 -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - ;;; Commentary: ;; ;; This library offers two functions that perform schema validation. @@ -45,10 +32,26 @@ ;; matches. The function `validate-variable' verifies whether the value of a ;; custom variable matches its custom-type, while `validate-value' checks an ;; arbitrary value against an arbitrary schema. +;; +;; Missing features: `:inline', `plist', `coding-system', `color', +;; `hook', `restricted-sexp'. -;;; Todo: +;;; License: +;; +;; This file is part of GNU Emacs. ;; -;; :inline, `plist',`coding-system',`color',`hook',`restricted-sexp'. +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . ;;; Code: (require 'cl-lib) @@ -172,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