bug#6617: linux kernel C style (fwd)

Sean Whitton <[email protected]>
Newsgroups gmane.emacs.cc-mode.general
Message-ID <871r5yyl8p.fsf__22783.5374463879$1632566113$gmane$org@melete.silentflame.com>
Hello,

On Wed 08 Sep 2021 at 10:40AM +02, Lars Ingebrigtsen wrote:

> Dan Nicolaescu <[email protected]> writes:
>
>> 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)
>>> {
>
> (I'm going through old bug reports that unfortunately weren't resolved
> at the time.)
>
> It still seems to be the case that the "linux" style indents using both
> tabs and spaces in Emacs 28.  I don't know what the Linux kernel style
> is these days, but the suggestion in this bug report is to add a
> tab-only variant.  Alan, do you have any comments about this?

The Linux kernel style is tabs only.  I think that Emacs DTRT if
indent-tabs-mode is t.  So, currently I have this fix in my init file:

    (c-add-style "linux-tabs" '("linux" (indent-tabs-mode . t)))
    (setq c-default-style "linux-tabs")

-- 
Sean Whitton
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.