Function: safe-local-variable-p

safe-local-variable-p is a byte-compiled function defined in files.el.gz.

Signature

(safe-local-variable-p SYM VAL)

Documentation

Non-nil if SYM is safe as a file-local variable with value VAL.

It is safe if any of these conditions are met:

 * There is a matching entry (SYM . VAL) in the
   safe-local-variable-values user option.

 * The safe-local-variable property of SYM is a function that
   evaluates to a non-nil value with VAL as an argument.

View in manual

Probably introduced at or before Emacs version 22.1.

Source Code

;; Defined in /usr/src/emacs/lisp/files.el.gz
(defun safe-local-variable-p (sym val)
  "Non-nil if SYM is safe as a file-local variable with value VAL.
It is safe if any of these conditions are met:

 * There is a matching entry (SYM . VAL) in the
   `safe-local-variable-values' user option.

 * The `safe-local-variable' property of SYM is a function that
   evaluates to a non-nil value with VAL as an argument."
  (or (member (cons sym val) safe-local-variable-values)
      (let ((safep (get sym 'safe-local-variable)))
        (and (functionp safep)
             ;; If the function signals an error, that means it
             ;; can't assure us that the value is safe.
             (with-demoted-errors "Local variable error: %S"
               (funcall safep val))))))