source formatting: what is supposed to be automatic now?

Milian Wolff mail at milianw.de
Sat Nov 26 14:57:27 UTC 2011


On Saturday 26 November 2011 15:40:56 David Nolden wrote:
> 2011/11/26 Milian Wolff <mail at milianw.de>:
> > Hey all, esp. David.
> > 
> > I saw all these commits recently regarding source formatting, and wonder
> > what is supposed to be improved now? I thought that the settings between
> > editor and formatter are now synchronized somehow?
> > 
> > But when I open e.g. sourceformattercontroller.h and override a method in
> > the class, just for the fun of it, like e.g. this one:
> > 
> > "virtual QAction* action (const QDomElement& element) const;"
> > 
> > I get it indented by four spaces, even though the rest uses two tabs.
> > 
> > Same if I e.g. implement a method, I alwasy get indentation by four
> > spaces,
> > even in files that only use two spaces.
> > 
> > Is this because I use astyle? Is all this not implemented there?
> 
> You get the indentation which you have configured in your
> source-formatter. If you use astyle, then you get the indentation
> which you have configured in astyle.

Should it not be vice-versa? The editor knows more specific settings for a 
given file, and imo the formatter should be configured accordingly?

> If you want "proper" formatting, eg. based on the per-directory rules
> defined in the "format_sources" files, then you need to select "Custom
> Script Formatter", and then "kdev_format_sources.sh".
> 
> Then you will get the editor settings matching the format_sources
> files (if you have uncrustify installed).
> 
> However, until now, I have defined 2-space indentation for most of my
> code, and 4-space indentation for the rest, so you will still get
> 4-space indentation in sourceformattercontroller.h. This has to be
> made consistent by either reformatting the code, or adapting the
> rules.

Right, I was remembering some new api that, given a document, guesses it's 
formatting. Apparently that was removed or I simply misremember that.

thanks for the clarifications.

bye
-- 
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20111126/ad4f54b8/attachment.sig>


More information about the KDevelop-devel mailing list