Thread: 4 spaces versus tabs

4 spaces versus tabs

From
Guillaume Lelarge
Date:
IIRC, we should use spaces and not tabs. If I look into the code, I see
many tabs in it. I can of course configure my editor to display them as
four tabs, but I would really like to get rid of them.

Any objections? because it would be a hell of a patch (90427 replacements)


--
Guillaume
 http://www.postgresql.fr
 http://dalibo.com

Re: 4 spaces versus tabs

From
Dave Page
Date:
On Sun, Oct 24, 2010 at 2:22 PM, Guillaume Lelarge
<guillaume@lelarge.info> wrote:
> IIRC, we should use spaces and not tabs. If I look into the code, I see
> many tabs in it. I can of course configure my editor to display them as
> four tabs, but I would really like to get rid of them.
>
> Any objections? because it would be a hell of a patch (90427 replacements)

Go for it. The project standard is for spaces.

Though, if we're going to make such a big change, I have to wonder if
tabs would be a more convenient choice in hindsight...

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Re: 4 spaces versus tabs

From
Magnus Hagander
Date:
On Sun, Oct 24, 2010 at 07:49, Dave Page <dpage@pgadmin.org> wrote:
> On Sun, Oct 24, 2010 at 2:22 PM, Guillaume Lelarge
> <guillaume@lelarge.info> wrote:
>> IIRC, we should use spaces and not tabs. If I look into the code, I see
>> many tabs in it. I can of course configure my editor to display them as
>> four tabs, but I would really like to get rid of them.
>>
>> Any objections? because it would be a hell of a patch (90427 replacements)
>
> Go for it. The project standard is for spaces.
>
> Though, if we're going to make such a big change, I have to wonder if
> tabs would be a more convenient choice in hindsight...

Also if going there - has anybody investigated if it's possible to get
pgindent to work on C++ files? Or if there's another similar tool we
could/should use?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/

Re: 4 spaces versus tabs

From
Guillaume Lelarge
Date:
Le 24/10/2010 08:05, Magnus Hagander a écrit :
> On Sun, Oct 24, 2010 at 07:49, Dave Page <dpage@pgadmin.org> wrote:
>> On Sun, Oct 24, 2010 at 2:22 PM, Guillaume Lelarge
>> <guillaume@lelarge.info> wrote:
>>> IIRC, we should use spaces and not tabs. If I look into the code, I see
>>> many tabs in it. I can of course configure my editor to display them as
>>> four tabs, but I would really like to get rid of them.
>>>
>>> Any objections? because it would be a hell of a patch (90427 replacements)
>>
>> Go for it. The project standard is for spaces.
>>
>> Though, if we're going to make such a big change, I have to wonder if
>> tabs would be a more convenient choice in hindsight...
>
> Also if going there - has anybody investigated if it's possible to get
> pgindent to work on C++ files? Or if there's another similar tool we
> could/should use?
>

I thought about it, but didn't actually look more into this. That could
be a better way to deal with it.


--
Guillaume
 http://www.postgresql.fr
 http://dalibo.com

Re: 4 spaces versus tabs

From
Guillaume Lelarge
Date:
Le 24/10/2010 08:10, Guillaume Lelarge a écrit :
> Le 24/10/2010 08:05, Magnus Hagander a écrit :
>> On Sun, Oct 24, 2010 at 07:49, Dave Page <dpage@pgadmin.org> wrote:
>>> On Sun, Oct 24, 2010 at 2:22 PM, Guillaume Lelarge
>>> <guillaume@lelarge.info> wrote:
>>>> IIRC, we should use spaces and not tabs. If I look into the code, I see
>>>> many tabs in it. I can of course configure my editor to display them as
>>>> four tabs, but I would really like to get rid of them.
>>>>
>>>> Any objections? because it would be a hell of a patch (90427 replacements)
>>>
>>> Go for it. The project standard is for spaces.
>>>
>>> Though, if we're going to make such a big change, I have to wonder if
>>> tabs would be a more convenient choice in hindsight...
>>
>> Also if going there - has anybody investigated if it's possible to get
>> pgindent to work on C++ files? Or if there's another similar tool we
>> could/should use?
>>
>
> I thought about it, but didn't actually look more into this. That could
> be a better way to deal with it.
>

Tried it on some of our source files. I think it'll require quite a lot
of work before we can have something more or less good.


--
Guillaume
 http://www.postgresql.fr
 http://dalibo.com

Re: 4 spaces versus tabs

From
Guillaume Lelarge
Date:
Le 24/10/2010 07:49, Dave Page a écrit :
> On Sun, Oct 24, 2010 at 2:22 PM, Guillaume Lelarge
> <guillaume@lelarge.info> wrote:
>> IIRC, we should use spaces and not tabs. If I look into the code, I see
>> many tabs in it. I can of course configure my editor to display them as
>> four tabs, but I would really like to get rid of them.
>>
>> Any objections? because it would be a hell of a patch (90427 replacements)
>
> Go for it. The project standard is for spaces.
>
> Though, if we're going to make such a big change, I have to wonder if
> tabs would be a more convenient choice in hindsight...
>

Actually, I don't like tabs :)

But I don't care that much. What I would like to have is a nice source
code, and, now, it doesn't look that nice.

So, if it is tabs, so be it :)


--
Guillaume
 http://www.postgresql.fr
 http://dalibo.com

Re: 4 spaces versus tabs

From
Benedek László
Date:
On 2010-10-24 17:05, Magnus Hagander wrote:

> > Also if going there - has anybody investigated if it's possible to get
> > pgindent to work on C++ files? Or if there's another similar tool we
> > could/should use?
> >
I use astyle for my C++ source code auto formatting. It has a lot of
formatting options. Maybe we can use it for pgadmin too, depending on
your preferred style.



Attachment

Re: 4 spaces versus tabs

From
Benedek László
Date:
On 2010-10-24 17:05, Magnus Hagander wrote:

> Also if going there - has anybody investigated if it's possible to get
> pgindent to work on C++ files? Or if there's another similar tool we
> could/should use?
>

I use astyle for my C++ source code auto formatting. It has a lot of
formatting options. Maybe we can use it for pgadmin too, depending on
your preferred style.


Attachment

Re: 4 spaces versus tabs

From
Guillaume Lelarge
Date:
Le 03/11/2010 01:05, Benedek László a écrit :
> On 2010-10-24 17:05, Magnus Hagander wrote:
>
>> Also if going there - has anybody investigated if it's possible to get
>> pgindent to work on C++ files? Or if there's another similar tool we
>> could/should use?
>>
>
> I use astyle for my C++ source code auto formatting. It has a lot of
> formatting options. Maybe we can use it for pgadmin too, depending on
> your preferred style.
>

I'm actually quite impressed with it. I worked a bit with it, and
"-pbSs4" seems to do quite good stuff for us.

Do you use other command line options with this tool?

Thanks a lot for this tool.


--
Guillaume
 http://www.postgresql.fr
 http://dalibo.com

Re: 4 spaces versus tabs

From
Benedek László
Date:
On 2010-11-03 17:58, Guillaume Lelarge wrote:
> I'm actually quite impressed with it. I worked a bit with it, and
> "-pbSs4" seems to do quite good stuff for us.
>
> Do you use other command line options with this tool?

I use a .astylerc file for my projects, which contains the following:

--style=java
--indent=tab=8
--indent-col1-comments
--indent-preprocessor
--indent-labels
--indent-switches
--align-pointer=type
--add-brackets
--pad-header
--pad-oper
--pad-paren
--unpad-paren

Please note, that these options are just my preferences for my sources.

The --style=java sets some predefined formatting options, not the source
language. The language is derived from the file extension or may be
forced by using a --mode=xxx option.

The complete astyle documentation is available here:
http://astyle.sourceforge.net/astyle.html

When you have a sufficient option set, I advise to add it to the git
repository too. If you want to strongly enforce that the committed codes
fits a given format, it is possible to write a git hook to reject
unfitting commits.


Attachment

Re: 4 spaces versus tabs

From
Robert Haas
Date:
On Tue, Nov 2, 2010 at 5:52 PM, Guillaume Lelarge
<guillaume@lelarge.info> wrote:
> Le 24/10/2010 07:49, Dave Page a écrit :
>> On Sun, Oct 24, 2010 at 2:22 PM, Guillaume Lelarge
>> <guillaume@lelarge.info> wrote:
>>> IIRC, we should use spaces and not tabs. If I look into the code, I see
>>> many tabs in it. I can of course configure my editor to display them as
>>> four tabs, but I would really like to get rid of them.
>>>
>>> Any objections? because it would be a hell of a patch (90427 replacements)
>>
>> Go for it. The project standard is for spaces.
>>
>> Though, if we're going to make such a big change, I have to wonder if
>> tabs would be a more convenient choice in hindsight...
>>
>
> Actually, I don't like tabs :)
>
> But I don't care that much. What I would like to have is a nice source
> code, and, now, it doesn't look that nice.
>
> So, if it is tabs, so be it :)

I like tabs, but that's just me, and I don't work on pgAdmin.  It
sucks trying to move back and forth between projects with different
styles, though, and pgsql uses tabs.

Another thing to consider if you're thinking about a massive fixup
commit is removing trailing whitespace.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Re: 4 spaces versus tabs

From
Guillaume Lelarge
Date:
Le 11/11/2010 22:10, Robert Haas a écrit :
> On Tue, Nov 2, 2010 at 5:52 PM, Guillaume Lelarge
> <guillaume@lelarge.info> wrote:
>> Le 24/10/2010 07:49, Dave Page a écrit :
>>> On Sun, Oct 24, 2010 at 2:22 PM, Guillaume Lelarge
>>> <guillaume@lelarge.info> wrote:
>>>> IIRC, we should use spaces and not tabs. If I look into the code, I see
>>>> many tabs in it. I can of course configure my editor to display them as
>>>> four tabs, but I would really like to get rid of them.
>>>>
>>>> Any objections? because it would be a hell of a patch (90427 replacements)
>>>
>>> Go for it. The project standard is for spaces.
>>>
>>> Though, if we're going to make such a big change, I have to wonder if
>>> tabs would be a more convenient choice in hindsight...
>>>
>>
>> Actually, I don't like tabs :)
>>
>> But I don't care that much. What I would like to have is a nice source
>> code, and, now, it doesn't look that nice.
>>
>> So, if it is tabs, so be it :)
>
> I like tabs, but that's just me, and I don't work on pgAdmin.  It
> sucks trying to move back and forth between projects with different
> styles, though, and pgsql uses tabs.
>

So go for it.

Just waiting to know Dave's opinion on all this before moving on.

> Another thing to consider if you're thinking about a massive fixup
> commit is removing trailing whitespace.
>

Oh, great idea. There's probably an option for that too.


--
Guillaume
 http://www.postgresql.fr
 http://dalibo.com

Re: 4 spaces versus tabs

From
Dave Page
Date:
On Thu, Nov 11, 2010 at 9:24 PM, Guillaume Lelarge
<guillaume@lelarge.info> wrote:
>
> Just waiting to know Dave's opinion on all this before moving on.

I'm leaning to tabs.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Re: 4 spaces versus tabs

From
Guillaume Lelarge
Date:
Le 11/11/2010 22:32, Dave Page a écrit :
> On Thu, Nov 11, 2010 at 9:24 PM, Guillaume Lelarge
> <guillaume@lelarge.info> wrote:
>>
>> Just waiting to know Dave's opinion on all this before moving on.
>
> I'm leaning to tabs.
>

OK. And no issue with me pushing such a huge patch?


--
Guillaume
 http://www.postgresql.fr
 http://dalibo.com

Re: 4 spaces versus tabs

From
Dave Page
Date:
On Thu, Nov 11, 2010 at 9:34 PM, Guillaume Lelarge
<guillaume@lelarge.info> wrote:
> Le 11/11/2010 22:32, Dave Page a écrit :
>> On Thu, Nov 11, 2010 at 9:24 PM, Guillaume Lelarge
>> <guillaume@lelarge.info> wrote:
>>>
>>> Just waiting to know Dave's opinion on all this before moving on.
>>
>> I'm leaning to tabs.
>>
>
> OK. And no issue with me pushing such a huge patch?

No. Please document the options you use though.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company