lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GOP-PROP 3: C++ formatting


From: Graham Percival
Subject: Re: GOP-PROP 3: C++ formatting
Date: Mon, 27 Jun 2011 13:45:54 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

On Sun, Jun 26, 2011 at 06:12:07PM -0700, Keith OHara wrote:
> On Sun, 26 Jun 2011 10:48:36 -0700, Graham Percival <address@hidden> wrote:
> 
> >A few specific problems with astyle:
> >    * it doesn’t indent enum in gnu style
>  I can't find gnu instructions for indenting enums, but if there are any the 
> astyle maintainers would probably want their gnu-mode to conform.

Yes, probably.  Unfortunately, the only real specification of "gnu
style" seems to be "whatever emacs does".

I'm not going to try hunting down more info about this, but if
anybody wants to investigate, and maybe discuss with the astyle
people, that would be great!

> >    * loses some nice comment formatting in ‘lily/axis-group-interface.cc’
>  If you mean line 592, it is fixcc.py that did the bad deed (as it has 
> already done elsewhere in master).  Astyle wins here.

Whoops, that's true!  I completely misread that diff.

> The most unusual aspect of gnu style is the space before open
> parentheses.  It would be nice to reduce all the review comments
> about this space to "run the format tool before you commit or
> push".

Aye, that's the main motivation behind this work.  If we're going
to insist on some syntax, and if that syntax can be added with
some automatic tool, then let's get that automatic tool in place!

> In your tests it seems only fixcc added this space, but astyle -Udp can do it.
> 
> Actually, astyle -Ud  inserts space /after/ the last right parenthesis as 
> well, when it is followed by another subexpression,
>   foo ((array*) [dir]);  a = me -> grob ()->spanned_rank_interval () [RIGHT];
> where Lilypond tends to have
>   foo ((array*)[dir]);   a = me -> grob ()->spanned_rank_interval ()[RIGHT];

When I add
  --pad-paren-out
  --pad-paren-oper
(which is what -dp does)

I see changes like this:
-      int barnum = measure_number (context());
+      int barnum = measure_number (context() );

That looks like a step backwards.  Granted, we could use some
regex to fix those mistakes, and run it on the output of astyle.
Basically, do exactly the same kind of post-processing that
fixcc.py does.

A really simple rule is:
    re.sub('[ \t]*\)', ')', line)
but that matches too many lines, it nukes the indentation of:
         "blah",
         "foo",
         );
A more sophisticated regex would fix this specific problem, of
course.


I think the most flexible solution would be to use
astyle+postprocessing, but it would take a few hours to get the
postprocessing script put together.

Cheers,
- Graham



reply via email to

[Prev in Thread] Current Thread [Next in Thread]