On Sun, Jul 5, 2009 at 7:08 PM, Alan W. Irwin<ir...@beluga.phys.uvic.ca> wrote: > However, because of the strong possibility that emacs may not be suitable > for changing the style of our old code, I started looking for other > coding-style tool alternatives, and the first one I found (called astyle) > looks interesting. Please take a look at > http://astyle.sourceforge.net/astyle.html for all the possibilities for > dealing with whitespace, parentheses, and brackets in programme source for > C, C++, and Java. It's a command-line tool with the possibility of using a > style file to control transforming our code base to our style consensus. > Thus, at first look it seems ideal for our needs, and I would appreciate > others here to look at it in more detail to make sure that really is the > case.
I used indent [1] a couple of times. [1] http://indent.isidore-it.eu/beautify.html If I understood plplot-c-style.el correctly (I'm a vim user), then here are appropriate indent options: #!/bin/bash INDENT_LEVEL=4 exec indent \ --no-blank-lines-after-declarations \ --blank-lines-after-procedures \ --brace-indent0 \ --braces-on-if-line \ --comment-indentation0 \ --case-brace-indentation$INDENT_LEVEL \ --declaration-comment-column0 \ --cuddle-do-while \ --cuddle-else \ --case-indentation$INDENT_LEVEL \ --space-after-cast \ --line-length80 \ --no-space-after-function-call-names \ --dont-break-procedure-type \ --no-tabs \ --indent-level$INDENT_LEVEL \ -T PLINT \ -T PLWindow \ -T BufferElement \ -T MasterHandler \ -T PLDispatchTable \ -T PLStream \ -T QObject \ -T QtEPSDevice \ -T QtExtWidget \ -T QtPLDriver \ -T QtPLWidget \ -T QtRasterDevice \ -T QtSVGDevice \ -T QWidget The problem with indent is that it doesn't know much C++ and sometimes doesn't get everything right. For example: delete[]xa; // no space after [] widget = dynamic_cast < QtRasterDevice *>((QtPLDriver *) pls->dev); // dynamic_cast<> parsed as "less" operator Also it needs hints about typedef'ed types. (The list above is not complete) astyle is much less strict that indent and it doesn't try to re-format everything like indent does. Here's a script for it: #!/bin/bash exec astyle \ --indent=spaces=2 \ --brackets=linux \ --indent-classes \ --indent-switches \ --indent-cases \ --pad-oper \ --unpad-paren \ --convert-tabs Dmitri -- main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if (j){printf("%d\n",i);}}} /*Dmitri Gribenko <griboz...@gmail.com>*/ ------------------------------------------------------------------------------ _______________________________________________ Plplot-devel mailing list Plplot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-devel