GNU bug report logs - #6617
linux kernel C style (fwd)

Previous Next

Packages: emacs, cc-mode;

Reported by: Dimitrios Apostolou <jimis <at> gmx.net>

Date: Mon, 12 Jul 2010 10:36:01 UTC

Severity: normal

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 6617 <at> debbugs.gnu.org (full text, mbox):

From: Dan Nicolaescu <dann <at> gnu.org>
To: Dimitrios Apostolou <jimis <at> gmx.net>
Cc: 6617 <at> debbugs.gnu.org
Subject: Re: bug#6617: linux kernel C style (fwd)
Date: Tue, 13 Jul 2010 08:51:30 -0400
Dimitrios Apostolou <jimis <at> gmx.net> writes:

> On Tue, 13 Jul 2010, Dan Nicolaescu wrote:
>> Dimitrios Apostolou <jimis <at> gmx.net> writes:
>>
>>> Hi, I sent the following to help-gnu-emacs and got no reply, maybe
>>> this list is more relevant.
>>>
>>> ---------- Forwarded message ----------
>>> Date: Thu, 8 Jul 2010 21:56:09 +0300 (EEST)
>>> From: Dimitrios Apostolou <jimis <at> gmx.net>
>>> To: help-gnu-emacs <at> gnu.org
>>> Subject: linux kernel C style
>>>
>>> Hello list,
>>>
>>> is the "linux" c-style supposed to be compliant to the linux kernel
>>> style guidelines? I just realised that all this time emacs was
>>> indenting my code slightly wrong, specifically the use of spaces is
>>> forbidden, even when continuing the argument list of a function.
>>
>> Is that really the case?  Is this requirement documented anywhere?
>
> In the file Documentation/CodingStyle search for "emacs". Warning: the
> language is a bit toxic for emacs devs/users.

There's code there that seems to do what you stated, but there seems
to be no text that actually describes that...

> There is also another point which is not clear but says the following:
>
> Statements longer than 80 columns will be broken into sensible
> chunks. Descendants are always substantially shorter than the parent
> and are placed substantially to the right. The same applies to
> function headers with a long argument list. Long strings are as well
> broken into shorter strings. The only exception to this is where
> exceeding 80 columns significantly increases readability and does not
> hide information.
>
>
> It is then followed by an example which is is indented only with tabs.
>
>
>> Looking at a random file in the linux-2.6.34.1 kernel:
>> kernel/sched.c one can see:
>>
>> static void update_group_shares_cpu(struct task_group *tg, int cpu,
>> 				    unsigned long sd_shares,
>> 				    unsigned long sd_rq_weight,
>> 				    unsigned long *usd_rq_weight)
>> {
>> [snip]
>>
>> The arguments starting from sd_shares are indented using a few tabs
>> followed by a few spaces.
>> The above is not the only occurrence, there are many others in the same file.
>
> My guess is that those are inconsistencies caused by the current
> "linux" style in emacs, but perhaps this should be posted to LKML to
> verify.

Please do that and report the conclusion here.

>> Another point: to enforce the use of the correct style, a file called
>> .dir-locals.el should be placed at the top level of the kernel tree
>> with the following [completely untested] contents:
>>
>> ((c-mode . ((c-file-style . "linux")
>>            (tab-width . 8)
>>            (indent-tabs-mode . t))))
>>
>> With this users of emacs-23+ will get the correct settings for editing
>> the kernel by default.
>>
>>
>
>
>
> Thanks,
> Dimitris




This bug report was last modified 3 years and 103 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.