Yes, possible. You need to change the definition of hack-local-variables-confirm
. Find the form (customize-push-and-save (if (= char ?!) ...))
and modify it.
I agree with you to some extent: these should be put into another file. But to be honest, I don’t recommend you change the function’s definition, because this is not elegant, so maybe we'll wait and see if there's any other way.
BTW, you can take a look at my code. (Please ignore the coding style; I will refactor it someday but not now.) try the code shown below. It doesn't answer your question (or, you could say that it answers, because the files that you trust are where the safe variables are.), but does solve your problem: you just need to put the .dir-locals.el
file’s path to your .emacs
, then Emacs will never ask you to confirm, because these variables are stored in safe-local-variable-values
and thus considered safe:
(setqlet custom((shynur/safe-local-variable-values (list)))
(named-let get-vars ((dir-locals
(mapcan (lambda (file-path)
"SOMEWHERE (when (file-ELSE/customexists-p file-path)
(with-temp-buffer
(insert-file-contents file-path)
(read (current-buffer)))))
["~/.emacs.d/.dir-locals.el"
"~/.emacs.d/.dir-locals-2.el"
;; Files that you trust ...
])))
(loaddolist custom(mode-filevars dir-locals)
(let ((vars (cdr mode-vars)))
(if (stringp (car mode-vars))
(get-vars vars)
(dolist (var-pair vars)
(push var-pair shynur/safe-local-variable-values))))))
(setq safe-local-variable-values (nconc shynur/safe-local-variable-values
safe-local-variable-values)))