I have the following .dir-locals.el for a project:
((nil . ((show-trailing-whitespace . nil)
(eval . (c-add-style "fontforge"
'("stroustrup"
(indent-tabs-mode . t)
(tab-width . 8)
(c-offsets-alist
(case-label . *)))))))
(c-mode . ((c-file-style . "fontforge"))))
The idea is to define a new c-style and apply it to all files in that project.
When I first visit a file under that project, I get the error: "Undefined style: fontforge"
When I examine c-style-alist, "fontforge" is the first entry, and when I look at c-file-style for that buffer, its value is "fontforge". However, as the error implies, the style has not been applied to that buffer: if I check the value of indent-tabs-mode, which I have configured globally to "nil", it is still nil.
If I then run M-x c-set-style RET fontforge RET, the style is applied as expected.
Hence, it appears my error has to do with the order of evaluation. I tried putting the "eval" sexp under the "c-mode" section of the .dir-locals.el, but that still gives the same error, even when I put it before the c-file-style sexp.