there is a .dir-locals in parent directory

((nil (global-auto-revert-ignore-buffer . t)))

and there is a .dir-locals in current directory

((nil (tags-file-name "TAGS")))

but when I visit files in current directory only tags-file-name directory variable are applied. but when I visit another subdirectory without .dir-locals, global-auto-revert-ignore-buffer are applied.

Could apply both directory variables in current directory?


1 Answer 1


No, there is no provision (at least as at Emacs 24.5) for additionally continuing to look for and process ancestor .dir-locals.el files after a nearer one has been located.

However, if it makes sense for your scenario, you can remove your "current directory" file and specify all the variables in the parent .dir-locals.el file.

Keys which are strings specify sub-directories; and the variables beneath that are set in addition to (or perhaps overriding) the ones in the top-level specifications.

See C-hig (emacs) Directory Variables, which provides the following example:

     ((nil . ((indent-tabs-mode . t)
              (fill-column . 80)))
      (c-mode . ((c-file-style . "BSD")
                 (subdirs . nil)))
       . ((nil . ((change-log-default-name
                   . "ChangeLog.local"))))))

This sets ‘indent-tabs-mode’ and ‘fill-column’ for any file in the
directory tree, and the indentation style for any C source file.  The
special ‘subdirs’ element is not a variable, but a special keyword which
indicates that the C mode settings are only to be applied in the current
directory, not in any subdirectories.  Finally, it specifies a different
‘ChangeLog’ file name for any file in the ‘src/imported’ subdirectory.
  • thanks, but if there is hack solution for my problem?
    – netawater
    Sep 13, 2016 at 8:50
  • @netawater I don't know how comfortable I'd be with any such hack. How would you manage conflict resolution? What about symlinks with n>1 valid parent directories? Mounted volumes? There are too many weird cases to consider – at least far too many for a hack written as an answer on emacs.SE. Sep 13, 2016 at 11:34

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.