I like the idea of .dir-locals.el
. I have my own .dir-locals.el
file in my home directory that should set all the variables for directories/files that I open unless there is .dir-locals.el
closer to the directory I open the file in. However, even though the file is recognized, directory variables for subdirectories are not applied to opened files.
This is my ~/.dir-locals.el
:
(("dev/school" .
((indent-tabs-mode . nil)
(c-basic-offset . 4)))
("dev/test" .
((indent-tabs-mode . nil)
(c-basic-offset . 4)))
(c-mode .
((c-file-style . "linux")
(c-basic-offset . 8))))
When I open file ~/dev/test/test.c
the variable indent-tabs-mode
is set to t
and c-basic-offset
is 8
.
(describe-variable 'c-basic-offset)
in that file tells me it is set to 8
from ~/.dir-locals.el
.
(describe-variable 'indent-tabs-mode)
in that file says it's value (t
) is just in its default state.
Can I somehow achieve the desired behaviour? What am I doing wrong? How are file paths mapped to subdirectories in ~/.dir-locals.el
?
Edit:
As Jonathan suggested, I also tried:
(;; dev/school subdir
("dev/school" .
;; dev/school specification for all modes
(nil . ((indent-tabs-mode . nil)
(c-basic-offset . 4)))))
and even what add-dir-local-variable
added:
(("dev/school"
(indent-tabs-mode)
(c-basic-offset . 4)))
Unfortunately, none of those work either.