On Apr 20, 7:18pm, der.hans wrote:
> Anybody know of a Free Software code beautifier? Something that lets me
> see code how I like it however it looks on disk and lets others bring it
> up in whatever heathen format they like?
For C (and maybe C++) code, there's GNU indent. See
http://www.gnu.org/software/indent/indent.html
I once worked for a small company where we had indentation wars. I
had written the bulk of the code in the project and some of my
colleagues would (in the process of working on it) reindent the code
with Emacs' defaults. When I got ahold of the code again, I'd reindent
it back the way that I liked it. We went back and forth like this for
a while; it was very painful doing merges between our code bases. I
finally learned about GNU indent and hacked it so that, once run, it
was a mostly idempotent operation. (I.e, once you'd indented to a
certain style, if you ran it again on the same code, nothing would be
changed.) It's a shame that I never did get around to contributing
those changes.
I've learned to be more tolerant of different styles in the years
since. In fact, these days, working on GDB, I'm using the very
indentation style that I found so repulsive those many years ago. My
advice these days is to be flexible and adapt to whatever style a
particular project has adopted. I also think it's important for a
project to standardize on a particular style and stick to it. It's
very annoying to have to switch indentation schemes between different
files in the same project (or even different functions in the same
file).
A related matter is defining (or agreeing upon) how many spaces a tab
expands to. Of course, the right answer is eight ;-), but, depending
on where I've worked, I've adapted to setting it to be four and other
strange values too.
Kevin