On Mon, May 19, 2014 at 10:51:52PM +0200 I heard the voice of
Rhialto, and lo! it spake thus:
> 
> For practical reasons, it helps a lot if one's editor (vim in my
> case) can be made to apply (at least some aspects of) the style
> automatically.  Especially tabs-vs-spaces since often you don't see
> if you get them wrong.

True.  Though I always have vim configured to show me tabs (and
trailing spaces) visually.  e.g., attached img, from 500-some lines
down ctwm.c.  You can see the tabs, as well as the trailing space on
the line with the cursor.  Also how some lines are "indented" by two
spaces FOLLOWED by a tab (presumably accidentally).  Makes it easier
to see when I step outside the lines.  Otoh, it rubs it in my face
everytime somebody else is inconsistent, which is maddening for me and
probably drives them nuts when I keep bringing it up too...


> Hmmm the part which removes spaces around parentheses is rather too
> agressive: I get lots of
> 
>     if(expr) foo();
>     while(expr) foo();
> 
> which I find really really ugly. () should be tight after function
> names but loose after keywords. And no return (expr).

I've never really gotten that distinction myself; I always prefer them
tight up.  I put it in because of the number of places in the code
where there's _tons_ of space around them, and not wanting to bother
dealing with that manually.  But maybe we could.

Now, the cramming the body on the same line as the conditional/loop,
that is nuts.  I tried finding a way to make it undo that, but I
couldn't.  I don't think astyle is _doing_ it, just preserving it from
the code.  It's got a keep-one-line-statements arg that makes it hold
them together, but no way I can find to tell it to break that crap up.


> 
> After applying first allman and then knf (which is really more my taste)
> on events.c, I got something like
> 
>     if(...) {
>       ...
>     }
>     else {
>       ...
>     }
> 
> which is another strange hybrid. I'd expect a reformatter to get that
> consistent...

If you mean the breaking after } that's not due to the running Allman
first (after all, a reformatter that didn't reformat is silly ;).
That's due to

    # Don't cuddle elses
    break-closing-brackets

in the knf.astyle.  I really hate cuddled elses   :)


> I suppose that can be compensated by setting tabsize to 4 in the
> editor, but that causes lots of trouble when external tools touch
> the file.

Eh, I usually run 4 char tabs (well, except on ctwm, with the amount
of mixing).  I haven't found other tools that much care.  Maybe
printing it out would take some filtering, but I haven't done that in
a lot of years.


> That's why I typically keep tabs at the standard 8 and let the
> editor handle indentation (4) in mixed tab and spaces. Although on
> the other hand some other people hate such mixing and prefer to do
> everything with spaces... (I don't mind that, myself)

Yeah, that's crazy-making.  :)

I like tabs, and don't much care for spaces, but mixing is definitely
the worst of all worlds.  It completely falls apart unless everyone
has the exact same size tabs; with all tabs, it works no matter what
your tabstop is (unless you have 15-char tabs and a 40-char term or
the like of course, but as long as it fits your environment).


> Can astyle reformat
> 
>       if(Tmp_win->AutoSqueeze && Tmp_win->squeezed) AutoSqueeze(Tmp_win);
> 
> to
> 
>       if (Tmp_win->AutoSqueeze && Tmp_win->squeezed)
>       {
>               AutoSqueeze(Tmp_win);
>       }
> 
> i.e. including the braces? I think that needs doing on a mass scale,
> too.

There's an add-brackets param, yeah.  It probably would force adding
the break as a side effect (which makes me consider running an
add-brackets followed by remove-brackets to kill off those hateful
one-liner things ;).  I don't dislike unbracketed oneliners.

See <http://astyle.sourceforge.net/astyle.html> for the list of config
options.


> (Oops, that remark may start a holy war after all, and that after
> being so careful to try and avoid that...)

How're we supposed to test out a new release, if people aren't flaming
through it?   ;)


-- 
Matthew Fuller     (MF4839)   |  [email protected]
Systems/Network Administrator |  http://www.over-yonder.net/~fullermd/
           On the Internet, nobody can hear you scream.

Reply via email to