Re: [hatari-devel] Proposal to introduce a configuration for a code formatting tool |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Hi,
On torstai 15 joulukuu 2011, Nicolas Pomarède wrote:
> Le 15/12/2011 17:58, Matthias Arndt a écrit :
>> Am Donnerstag, den 15.12.2011, 17:46 +0100 schrieb Nicolas Pomarède:
>>
>> I personally think that it helps a lot of files always have the same
>> look and feel.
This requires first agreeing on what format to use.
My preference is K&R and pretty close to this:
http://www.kernel.org/doc/Documentation/CodingStyle
It's used in my code and close to what Laurent uses in his source code and
how Aranym code looks (from which some parts are copied to Hatari).
However, lots of code in Hatari uses different brace style though.
(As Thomas mentioned, to work with open source projects, one needs
to be "fluent" in multiple code formatting styles although you
would use some specific one for your own code.)
>> I don't intend to touch all parts of the code so it can
>> be fine for me.
You can install your own Mercurial hooks that check or even re-format
your commits. See:
http://www.selenic.com/mercurial/hgrc.5.html#hooks
http://stackoverflow.com/questions/4162384/mercurial-pre-commit-hook
http://mercurial.selenic.com/wiki/Hook
This might be used as an example if you opt for extending Mercurial
in Python:
https://bitbucket.org/marcusl/ml-hgext/src/tip/checkfiles.py
> I agree for new files, for old files, seeing the few number of people
> that work on them and the fact that indenting is not that bad anyway, I
> think it's ok to keep it this way.
>
> > Seeing the "existing style" is sometimes very hard to see. I even think
> > the whole code was formatted to 4 spaces already. At least that aligned
> > okaish in Code::Blocks.
>
> Most code uses 'tab' in hatari, so setting tab=4 or 8 spaces in your IDE
> will keep it aligned, you won't realise the difference.
>
> The problem is that in some part of your patch (open it with vim for
> example), the tabs were exported as spaces instead of real tab. And tabs
> were replaced by 4 spaces, hence the indenting problem when pushing it
> to Hatari's tree.
Problem with tab!=8 settings is that some editors change spaces to TABs
whenever you edit a line that's starting with enough spaces for its TAB
setting.
> Check that your IDE has an option to automatically convert consecutives
> spaces to tabs, so they're exported as tabs later
For an editor to do indenting properly, it should use TABs only up to
the code block indenting level and after that use only spaces when
you press TAB-key. Otherwise things get messed up in viewers & editors
using different TAB settings.
> (and use 8 spaces per tab for Hatari, that the setting everywhere)
If editor doesn't automatically use TABs & spaces as described
above, only safe TAB setting is indeed 8. Or using 8 spaces.
- Eero