[gdal-dev] emacs configuration for correct code indentation?

Etienne Tourigny etiennesky.dev at gmail.com
Fri Sep 2 15:06:16 EDT 2011


Frank, please do send me your emacs macros.   With your permission I will
add that information to the wiki as suggested by Even.

I agree with your policy of not being too strict, but a minimal set of
standards is a good thing IMHO.
It could help in elaborating a suggested standard in the wiki page (just my
2 cents).

Two issues that come to mind are

1) where to put opening braces in if/else/for blocks  It can get a little
messy, as different flavors are used by different people

if ( 1 ) {
...
}
vs
if ( 1 )
{
...
}

2) one-liner if/else statements without braces.  Some projects like qgis
discourage their use, but personally I like it more compact


thanks, Etienne

On Fri, Sep 2, 2011 at 3:45 PM, Frank Warmerdam <warmerdam at pobox.com> wrote:

> On Fri, Sep 2, 2011 at 11:29 AM, Even Rouault
> <even.rouault at mines-paris.org> wrote:
> >> (setq-default c-basic-offset 4
> >>           tab-width 4
> >>           indent-tabs-mode nil)
> >> (c-set-offset 'case-label '+)
> >
> > Not sure if it is RFC material, but you can definitely share it in
> > http://trac.osgeo.org/gdal/wiki/HowToContribute
> >
> > You have summed up perfectly the most important coding conventions.
>
> Etienne,
>
> Agreed, 4 character indent using spaces not
> tabs is the key thing to avoid messiness for others.
>
> > You have also probably noticed the nice visual ascii art that is
> generally
> > prepended before each function/method :
> >
> >
> /************************************************************************/
> > /*                               foo()
>  */
> >
> /************************************************************************/
>
> I actually have emacs macros for editing these header blocks.
> I could share them if you are interested, but they are not that
> critical.
>
> I deliberately have avoided trying to be really strict about code
> formatting in GDAL/OGR.  I think over-strictness can be offputting
> to new contributors and lead to disputes over details.  But do
> make an effort to fit into the modules you work on and feel
> free to take more liberties on drivers that you are writing from
> scratch.
>
> > And if you really want to confuse FrankW and make him believe he has
> written
> > the code himself, you'd write if( foo ) rather than if (foo) ;-)
>
> This is one of the details that seems fairly idiosyncratic
> to me, but it is contrary to Google code style so perhaps
> I will adapt to "if (foo)" now.
>
> Best regards,
> --
>
> ---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up   | Frank Warmerdam,
> warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush    | Geospatial Software Developer
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110902/af74ad51/attachment-0001.html


More information about the gdal-dev mailing list