a quick question in case someone has done this before:
I'm trying to stop Emacs from trying to recursively open .dir-locals.el
under all parent subdirectories when opening a file. I have found how to stop it completely (by forcing all files to be remote - the opposite of this: In Emacs, how do I use directory local variables for remote projects?) but I would like to allow access to at least the .dir-locals.el
in the current directory of the file Emacs is editing, or implement a similar solution to the GIT_CEILING_DIRECTORIES
variable (where git stops looking for .git
after reaching a specific directory defined in this variable).
I have no experience with Emacs unfortunately.
EDIT: A sample from strace
when I run emacs testfile
in /tmp/test/a/b/c/d
.
stat("/tmp/test/a/b/c/d/.dir-locals.el", 0x7ffe15dd1ee0) = -1 ENOENT (No such file or directory)
stat("/tmp/test/a/b/c/.dir-locals.el", 0x7ffe15dd1ee0) = -1 ENOENT (No such file or directory)
stat("/tmp/test/a/b/.dir-locals.el", 0x7ffe15dd1ee0) = -1 ENOENT (No such file or directory)
stat("/tmp/test/a/.dir-locals.el", 0x7ffe15dd1ee0) = -1 ENOENT (No such file or directory)
stat("/tmp/test/.dir-locals.el", 0x7ffe15dd1ee0) = -1 ENOENT (No such file or directory)
stat("/tmp/.dir-locals.el", 0x7ffe15dd1ee0) = -1 ENOENT (No such file or directory)
stat("/.dir-locals.el", 0x7ffe15dd1ee0) = -1 ENOENT (No such file or directory)
This is not happening for example in /home/user/a/b/c/d
, and it stops looking when it reaches /home/user
.
EDIT2: Some more information regarding why I'm looking for a solution to this:
the directory /mnt/groups/
is automounting directories such as /mnt/groups/project1
, /mnt/groups/workA
, /mnt/groups/final_presentation
, where users are allowed to work. When a user launches Emacs inside e.g. /mnt/groups/project1/documentation
, Emacs searches for .dir-locals.el
, .bzr
, .git
, _MTN
etc through every parent subdirectory until it reaches /
. I've used vc-ignore-dir-regexp
(in a file in site-start.d
, so it would apply globally) to stop it from looking for version control related directories after /mnt/groups
, but I cannot stop it from doing the same for .dir-locals.el
. While I've blacklisted .dir-locals.el
in the automounter (so a solution is partially in place for my problem), I would prefer to stop Emacs altogether from going through all parent subdirectories. I tried setting locate-dominating-stop-dir-regexp
but it didn't seem to affect looking for .dir-locals.el
, unless it is somehow clashing with vc-ignore-dir-regexp
. Unfortunately, as I mentioned, I have no experience with Emacs (I'm not using it myself) so I wasn't able to understand how to program anything more advanced.