I have some customization in my .dir-locals.el. Some of variables set there are unsafe and when I set them and visit some file in dir for the first time Emacs nicely asks me to save their name-value pairs for future use in the current session.
There is a bit different story when variable is also considered as risky, then Emacs do not offer the choice to safe them for the future use and asks for the permission every time I visit any file in dir.
I've read that it is actually desirable Emacs behavior but it's a bit impractical to me.
I want to set up some variables for my project, put .dir-locals.el on git and let others in my team use my customizatins.

Mentioned documentation claims:

Emacs always queries before setting a risky variable, unless the user explicitly allows a value by customizing safe-local-variable-values directly.

What I've tried is:

  . ((eval . (add-to-list 'safe-local-variable-values
                          '(projectile-test-suffix-function (lambda (_) ""))))
      . (lambda (_) "")))))

And it has no effect - it still asks for permission every time I visiting a file in dir.

What I'm doing wrong?

  • 2
    If you could declare a setting to be safe from the same file that does the setting, it would defeat the whole point of having risky/safe variables/values...
    – npostavs
    Oct 17, 2016 at 21:56
  • What with the point of directory/project local customization? :) Do you have some other idea on this? I'm tying to achieve project local settings which could be part of project's code base on git.
    – yujaiyu
    Oct 17, 2016 at 22:09
  • The safety part has to be done non-locally.
    – npostavs
    Oct 17, 2016 at 22:12
  • 1
    I suggest you M-x report-emacs-bug asking to be prompted to save the value as being safe, just like we do for other variables.
    – Stefan
    Oct 18, 2016 at 0:03
  • 2
    Whether the maintainers will consider it as a bug or not is up to them. But you as a user can decide that you consider it as a bug, and the maintainers generally like to know that, even if in the end they decide to disagree.
    – Stefan
    Oct 18, 2016 at 11:52


Your Answer

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