[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question about dir-locals c-mode.
From: |
Daniel Martín |
Subject: |
Re: Question about dir-locals c-mode. |
Date: |
Sun, 08 Nov 2020 14:39:49 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin) |
Ergus <spacibba@aol.com> writes:
> Hi:
>
> This is probably a basic question, but I don't find any reference.
>
> I have a .dir-locals.el file a bit long because the project implied is a
> bit special regarding indentation. The problem is that the project is
> either C and C++ code and the indentation in both cases is retty much
> the same; but other files like python, bash or makefiles require
> different indentation.
>
> I am wondering if it is possible in the dir-locals to set a
> configuration either for C and C++ without repeating myself.
>
> Up to now I have:
>
> (c++-mode . (...Long...))
> (c-mode . (...Long...))
>
> But everytime I update the C config I have to copy and paste in the
> other...
>
> is it possible to do something equivalent to:
>
> ((or c-mode c++-mode) . (...Long...))
>
> Thanks in advance,
> Ergus
There's no special syntax to match several major modes in
.dir-locals.el. One alternative is to put your C and C++ configuration
under prog-mode and add specific entries for Python, Bash and Makefiles
modes.
Another alternative may be to use the "eval" variable to call a common
function that sets the file-local variables. Something like:
((c++-mode . ((eval . (apply-common-c-configuration))))
(c-mode . ((eval . (apply-common-c-configuration)))))