source formatting: what is supposed to be automatic now?

David Nolden david.nolden.kdevelop at art-master.de
Sat Nov 26 15:06:09 UTC 2011


2011/11/26 Milian Wolff <mail at milianw.de>:
> 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?

The editor knows only the indentation-depth, which is 0.1% of the
formatting configuration, therefore the formatter knows much more, and
the editor is what should be adapted accordingly. Also the
formatting-script can work independently of kate or kdevelop (it just
needs uncrustify and the "kdev_format_sources.sh"), thus it is a much
cleaner solution than distributing .kateconfig and modelines all
around. For example, it could easily be integrated into a commit-hook.




More information about the KDevelop-devel mailing list