[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#6617: linux kernel C style (fwd)

From: Dan Nicolaescu
Subject: bug#6617: linux kernel C style (fwd)
Date: Tue, 13 Jul 2010 08:51:30 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

Dimitrios Apostolou <address@hidden> writes:

> On Tue, 13 Jul 2010, Dan Nicolaescu wrote:
>> Dimitrios Apostolou <address@hidden> 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 <address@hidden>
>>> To: address@hidden
>>> 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- 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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]