* Question about dir-locals c-mode.
[not found] <20201107235056.5lwabkhbflx2gc6o.ref@Ergus>
@ 2020-11-07 23:50 ` Ergus
2020-11-08 6:22 ` Jean Louis
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Ergus @ 2020-11-07 23:50 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Question about dir-locals c-mode.
2020-11-07 23:50 ` Question about dir-locals c-mode Ergus
@ 2020-11-08 6:22 ` Jean Louis
2020-11-08 13:39 ` Daniel Martín
2020-11-08 14:50 ` Stefan Monnier
2 siblings, 0 replies; 6+ messages in thread
From: Jean Louis @ 2020-11-08 6:22 UTC (permalink / raw)
To: Ergus; +Cc: help-gnu-emacs
* Ergus <spacibba@aol.com> [2020-11-08 02:52]:
> 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.
Did you try with local file variables?
M-x add-file-local-variable
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Question about dir-locals c-mode.
2020-11-07 23:50 ` Question about dir-locals c-mode Ergus
2020-11-08 6:22 ` Jean Louis
@ 2020-11-08 13:39 ` Daniel Martín
2020-11-08 14:50 ` Stefan Monnier
2 siblings, 0 replies; 6+ messages in thread
From: Daniel Martín @ 2020-11-08 13:39 UTC (permalink / raw)
To: Ergus; +Cc: help-gnu-emacs
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)))))
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Question about dir-locals c-mode.
2020-11-07 23:50 ` Question about dir-locals c-mode Ergus
2020-11-08 6:22 ` Jean Louis
2020-11-08 13:39 ` Daniel Martín
@ 2020-11-08 14:50 ` Stefan Monnier
2020-11-08 16:16 ` Ergus
2 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2020-11-08 14:50 UTC (permalink / raw)
To: help-gnu-emacs
> Up to now I have:
>
> (c++-mode . (...Long...))
> (c-mode . (...Long...))
FWIW, I had sent a patch to CC-mode to introduce a parent mode shared by
c-mode, c++-mode, and objc-mode, but Alan didn't like the idea.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Question about dir-locals c-mode.
2020-11-08 14:50 ` Stefan Monnier
@ 2020-11-08 16:16 ` Ergus
2020-11-08 17:58 ` Stefan Monnier
0 siblings, 1 reply; 6+ messages in thread
From: Ergus @ 2020-11-08 16:16 UTC (permalink / raw)
To: Stefan Monnier; +Cc: help-gnu-emacs
On Sun, Nov 08, 2020 at 09:50:38AM -0500, Stefan Monnier wrote:
>> Up to now I have:
>>
>> (c++-mode . (...Long...))
>> (c-mode . (...Long...))
>
>FWIW, I had sent a patch to CC-mode to introduce a parent mode shared by
>c-mode, c++-mode, and objc-mode, but Alan didn't like the idea.
>
>
> Stefan
:( There is the c-mode-common-hook I was actually expecting that there
should be something like c-mode-common. Somehow it seems intuitive for
me. Some packages like irony have actually some hacks to go around this
too.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Question about dir-locals c-mode.
2020-11-08 16:16 ` Ergus
@ 2020-11-08 17:58 ` Stefan Monnier
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2020-11-08 17:58 UTC (permalink / raw)
To: Ergus; +Cc: help-gnu-emacs
>>> (c++-mode . (...Long...))
>>> (c-mode . (...Long...))
>>FWIW, I had sent a patch to CC-mode to introduce a parent mode shared by
>>c-mode, c++-mode, and objc-mode, but Alan didn't like the idea.
> :( There is the c-mode-common-hook I was actually expecting that there
> should be something like c-mode-common. Somehow it seems intuitive for
> me. Some packages like irony have actually some hacks to go around this
> too.
Note that `c-mode-common-hook` is not just common to C-like languages
but applies to all modes using the CC-mode framework, which includes
java-mode, awk-mode, php-mode, sieve-mode, and various others. So it
risks being "too common" for the kind of usage you describe (and yes, my
patch had two parent modes: one common to C, C++, and ObjC, and another
one on top common to all CC-mode derivatives).
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-11-08 17:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20201107235056.5lwabkhbflx2gc6o.ref@Ergus>
2020-11-07 23:50 ` Question about dir-locals c-mode Ergus
2020-11-08 6:22 ` Jean Louis
2020-11-08 13:39 ` Daniel Martín
2020-11-08 14:50 ` Stefan Monnier
2020-11-08 16:16 ` Ergus
2020-11-08 17:58 ` Stefan Monnier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).