trinity-devel@lists.pearsoncomputing.net

Message: previous - next
Month: January 2015

Re: [trinity-devel] Codebase formatting discussion

From: Michele Calgaro <michele.calgaro@...>
Date: Thu, 01 Jan 2015 15:22:08 +0900
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 01/01/2015 04:27 AM, Timothy Pearson wrote:
>> On 2014/12/31 02:13 PM, Timothy Pearson wrote:
>>>>> Yes, we can wait a few days for your input. :-)
>>>>> 
>>>>> The vast majority of this file was written in the style I prefer: 
>>>>> https://git.trinitydesktop.org/cgit/tdelibs/tree/tdecore/tdehw/tdehardwaredevices.cpp?id=f27e71dcb162e37234ea98570379f60f8afdd8ea
>>>>>
>>>>>
>>>>>
>>
>>>>> 
I noticed on quick glance that at least one alternate styles snuck in
>>>>> over time, so the revision ID specified in that link is an older version without many of the changes that
>>>>> introduced those alternate styles.
>>>>> 
>>>>> I find it very easy to read on mutiple screens, on the Web and in Kate, from small laptops up to my main
>>>>> workstation. Comments are of course welcome!
>>> 
>>>> If my vote still counts, I have only one request: please do not use 8 spaces for tabs. I prefer only 2
>>>> spaces, but 4 is acceptable.
>>> 
>>>> Darrell
>>> 
>>> I prefer hard tabs, this way each developer can set the space the way they want to see it.
>>> 
>>> Tim
>>> 
>> Tim, just wondering. What tool do you use to reformat existing code? Cheers Michele
> 
> AStyle.  In fact I was working on this in late 2012: https://git.trinitydesktop.org/cgit/scripts/tree/astyle
> 
> Tim
> 

Hi Tim,
well, first of all Happy New Year.

I had a closed look at astyle and played around with it quite a while. I have attached an alternative option file,
which generates code closer to my favorite style. These are just my preferences, it doesn't mean we need to use it
exactly as it is. In particular the most important points are:

1) style: I prefer broken parenthesis instead of attached ones
2) hard tabs: ok with that. But use the force-tab option
3) no indent-cases blocks, too much indentations.
4) indent preprocessor defines on multiple lines
5) the "--break-blocks" is somehow optional. I have included it, but even without it will do.
6) --pad-oper, --pad-header, --unpad-paren: I prefer something like
       if (a == b)
   rather than
       if( a==b )
7) "--delete-empty-lines" ok if "--break-blocks" is used

Everything else is quite minor.

I have also attached the outputs created using the script currently in GIT and mine. Don't bother about the code
itself, it was just made up for testing.

Cheers
  Michele

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCgAGBQJUpOePAAoJECp1t8qK3tXPz08P+QFUAoDdOBS21s6VE6pODkuF
yizYSlAcWzJqCTdfWStXFPJIwsG05fRx/vmN9I3CGhaFjb3G6+iq/bKUOR00jvto
N92ydCbCzTbk16AHEVpwpcvkxQW8kT4qYD5wMXdCzyQI3wKOWcWhu6FozBzt0DZk
jFGlcJV+C6opE/TEobnkR/0QutzSifR8mP2D2ozJcYc/UQxr/5ePkim1u8EwlgXr
MMq8aAGbBNyPgwDdMJjH2/0f4uF2wRLHPopcJ3WlemF5RvBbdiEZe8eYkCkj4Upe
gpRpNUxD3UT/VSpq4Pf9l7GvOQ890cc1P4xC5ueDT+jLbR6vYVENHPbvxtm6PufR
vSD80wz5xpg7Oy1lvRgCr3OSu3EBtqOFXzzYBO/TzJ07GLowWvrPYxso1X30wgbB
3lhtslQyGnTP2mwijkZMp51UCT5lP51a+WDJTjSOP7b1KnyYeda5jIVOyiN7vvC3
VBXb3GXhauTfkOE4HQjaXbieNsGZzrx8rrBw3Kfbn7qx0TTDQntW/aE6u03Ith3a
tO45EBhHYMGMDKLgu3GEg/S9ciWMEE9RiCoTkoOnopzXGdC04xrQgos2F3dni4S9
2EWosTBKjwYBcfwOcQpqkek+ul27XiAPPgv2q68JWGbGRxmXi4LrqpKIboIDua7u
mfmS9GCRCmflY7MRJsuG
=zcd7
-----END PGP SIGNATURE-----
--style=allman
--lineend=linux

--indent=force-tab
--indent-classes
--indent-switches
--indent-namespaces
--indent-labels
--indent-preproc-define
--indent-col1-comments
# --indent-preproc-block  # does not worked here - astyle 2.04 - Debian/Jessie
--min-conditional-indent=2

--break-blocks
--delete-empty-lines

--pad-oper
--pad-header
--unpad-paren

--align-pointer=name
--add-brackets

--max-code-length=100
--break-after-logical

--suffix=none

Attachments: