public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Benny Halevy <bhalevy@panasas.com>
To: James Courtier-Dutton <James@superbug.co.uk>
Cc: Xavier Bestel <xavier.bestel@free.fr>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: Coding Style: indenting with tabs vs. spaces
Date: Mon, 12 Nov 2007 10:13:08 +0200	[thread overview]
Message-ID: <47380B14.3010604@panasas.com> (raw)
In-Reply-To: <4736CA1D.9020507@superbug.co.uk>

On Nov. 11, 2007, 11:23 +0200, James Courtier-Dutton <James@superbug.co.uk> wrote:
> DervishD wrote:
>>     Bonjour Xavier :)
>>
>>  * Xavier Bestel <xavier.bestel@free.fr> dixit:
>>   
>>> Le samedi 10 novembre 2007 à 13:04 +0100, DervishD a écrit :
>>>     
>>>>  * Benny Halevy <bhalevy@panasas.com> dixit:
>>>>       
>>>>> I would like to hear peoples opinion about the indentation convention
>>>>> described below that I personally found the most practical with
>>>>> several different editors.
>>>>>         
>>>> While I respect you opinion about tabs, I find tab indentation the most
>>>> evil thing ever invented. Even if done right (that is, not indenting
>>>> using a mixture of spaces and tabs), the only advantage is that you save
>>>> a few bytes.
>>>>       
>>> Who cares ?
>>>     
>> About the space saving? Not me, of course. It's just that I didn't see
>> any other advantage.
>>
>>   
>>> The only advantage is that people can make tabs as big (or as small)
>>> as they wish. Tabs become "logical indentation". So one's indentation
>>> isn't forced on anotherone's editor.
>>>     
>> The only way of having a sane indentation using tabs is to make sure
>> that ALL indentation are tabs, not a mix of tabs and spaces (spaces, if
>> any, should be at the end of indentation for aesthetical purposes, but
>> should be removed without the logical indentation being lost). A good
>> editor can ensure that all indentation are tabs and not a mix, but a
>> good editor can adapt indentation to your likings when loading the file
>> and save the file translating your favourite indentation back to spaces
>> or whatever.
>>
>> If everybody used tabs correctly, indenting using tabs would be great,
>> but IMHO indenting with spaces is much better.
>>
>>     Raúl Núñez de Arenas Coronado
>>
>>   
> 
> Just use the linux
> 
> ./scripts/checkpatch.pl --file
> 
> It does all the indent checks for you before you submit a patch.
> I.e. I checks that one has not mixed tabs with spaces etc.
> So, any patches to the Linux kernel will have tabs used correctly.
> Where is the problem?

checkpatch allows to indent with any number of tabs and up to 7 spaces.
This is consistent with Documentation/CodingStyle and therefore can be
considered "correct".  However, forcing everybody to the same tab expansion
setup is too limiting, especially when working in several environments
at the same time where some of them may not be the linux kernel.

Using only spaces as DervishD suggested works around that using brute force
by forcing the user to the author's preference which is legitimate but
may not be the most productive way.

I think that my proposal of using tabs as logical indents only (as Xav put it)
and spaces for decorative alignment provides the best of both worlds.
One can expand the tabs to any number of spaces as one likes and then
the trailing spaces will work on any editor setup as long as you use
fixed-width font.  That's not considered "correct" as per checkpatch but
works much better for me.

Benny

> 
> James
> 
> 
> -


  reply	other threads:[~2007-11-12  8:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-08 10:36 Coding Style: indenting with tabs vs. spaces Benny Halevy
2007-11-08 15:58 ` Chris Snook
2007-11-12  8:17   ` Benny Halevy
2007-11-10 12:04 ` DervishD
2007-11-10 12:27   ` Xavier Bestel
2007-11-10 16:50     ` DervishD
2007-11-11  9:23       ` James Courtier-Dutton
2007-11-12  8:13         ` Benny Halevy [this message]
2007-11-12 15:38           ` J. Bruce Fields
2007-11-12 16:30           ` DervishD
2007-11-11  8:57     ` Benny Halevy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47380B14.3010604@panasas.com \
    --to=bhalevy@panasas.com \
    --cc=James@superbug.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xavier.bestel@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox