When collaborating on a project, certain editing variables are set to make sure everyone is producing a similar style of code. In Emacs, these are usually implemented as either file-local variables or directory-local variables.

File-local variables are best when you want to keep the variable's value attached to the file itself, but they get cumbersome when it is the same variable over and over again for every file in the project.

Using a directory-local variable would be the obvious choice, but I'm personally using this to set the email I use in the project (as opposed to my work email, etc.) to make sure I'm never inconsistent with my commit data.

Is there a way around this problem? Can I have two files holding directory-local variables in the same directory (one personal file and one version-controlled file)?

Refer: sx.el@3a5afcc

up vote 7 down vote accepted

This seems to work:

(defadvice hack-dir-local-variables (around second-dir-locals-file activate)
  ad-do-it
  (let ((dir-locals-file ".alt-dir-locals.el"))
    ad-do-it))
  • Will this apply both .dir-locals.el and .alt-dir-locals.el in that order? – Sean Allred Dec 10 '14 at 21:21
  • It does, according to my simple testing. – Sean Dec 10 '14 at 21:35
  • Sweet! I'll try this out tomorrow :) – Sean Allred Dec 11 '14 at 0:13

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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