On 13-11-10 03:35 PM, James Brierley wrote:
Ah, this has reminded me: I forgot to mention, but perhaps it would be possible (for someone) to write a plugin which pipes your code through something such as Uncrustify, which is a modern version of the classic Unix utility ‘cb’. You would still need to hit a button to beautify your code (rather like the XML PrettyPrinter plugin) but at least it might be one way of having configurable indentation without costly on-the-fly parsing.
I’d have a go at this myself, but for the fact that I’m a CS graduate student (learning all that new stuff is great but why do they have to give you piles of coursework as well? :P)
I wrote and use such a plugin for C/C++/Obj-c using Clang-Format. I actually use it "real-time" just always keeping my code perfectly formatted (triggers on a set of configurable chars like closing braces and semicolons and such), but auto/realtime formatting isn't on by default and you can choose to format a selection, document, or all open documents rather than having it in "real-time"/automatic mode.
It's here: http://codebrainz.github.io/code-format/
And a boring demo video is here: http://codebrainz.ca/screencasts/GeanyCodeFormatC++.avi
I think Colomban also started working on a more general purpose version of something like this using GNU Indent, Astyle or Uncrustify (or one of those), but I'm not sure how far it got.
Cheers, Matthew Brush