I want to put some config outside my init.el file into .dir-locals.el, i.e the following:

  (let ((dirs '(".cask" "core" "packages" "modules" "snippets" "themes")))
   (mapc #'(lambda (path) (add-to-list 'projectile-globally-ignored-directories path)) dirs))))

But each time i'm trying to open any file in my .emacs.d folder, emacs asks me if it's save to apply this code. I've tried to silence it by setting file local vars:

;; -*- enable-local-variables: t; enable-local-eval: t -*-

and it didn't help at all, on the contrary adds another message to trust these local settings. How can i make it trust my .dir-locals.el code?

  • You've bound a variable named let
    – phils
    Commented Sep 13, 2016 at 22:58

1 Answer 1


You can customize safe-local-variable-values in your init file. This will require you to also specify which values you consider safe.

(add-to-list 'safe-local-variable-values '(var . value))

This is OK if you know the set of possible values, as your question implies you do.

If you want to make a variable safe for all values that satisfy a predicate, you can do:

(put 'var 'safe-local-variable #'stringp) 
  • Thank you for this approach, but as i wrote i want to put this config in .dir-locals.el
    – 4lex1v
    Commented Dec 11, 2015 at 16:42
  • You would still configure the projectile setting in a .dir-locals.el. But you will continue to receive warnings upon loading that file, until you take one of these actions. Have you tried the 2nd? That code, in your init file, replacing 'var with projectile-globally-ignored-directories, should prevent the warnings when the .dir-locals.el is loaded.
    – InHarmsWay
    Commented Dec 11, 2015 at 17:58
  • Although thinking about it, you may need '#listp rather than '#stringp, since you are setting the bar to a list of strings.
    – InHarmsWay
    Commented Dec 11, 2015 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.