Automatic indentation-detection in Kate and KDevelop

Milian Wolff mail at milianw.de
Wed Jun 22 14:08:44 UTC 2011


On Wednesday 22 June 2011 01:56:12 Tirtha Chatterjee wrote:
> Hi to Kdevelop and Kate developers!
> 
> I struck upon an idea today which I think would be very helpful both
> in Kate and in KDevelop.
> The idea is to have Kate/KDevelop automatically detect the indentation
> of a file by analyzing
> the leading tabs and spaces in the lines. It adjusts the tab width and
> sets wether to use tabs or
> to use spaces or mixed.

The idea is great but impossible to implement without some neuronal network / 
AI ;-) Many have tried, all have failed.

> This can be presented as a setting 'automatically adjust indentation'.
> But the behavioral aspects
> will be a little different in KDevelop and Kate. Here are test cases for
> each
> 
> Kate: The setting works in combination with the other indentation
> options. That is, when the user
> opens an existing file, the indentation settings change to that file's
> indentation. But if a new file is
> opens, the settings use the default settings set by the user, as fallback.

Problem 1: There are files with mixed tabs/spaces even though they should have 
only spaces or tabs and vice versa.

> KDevelop: Here we don't just work with individual files, but projects.
> So, suppose I open/import a
> project, and create a new class. Here, i should set the indentation
> settings by parsing the other
> files in the project, when they are all imported. Thus, each project
> can have its indentation settings,
> and if a file is outside a project, then it uses Kate's way of dealing with
> it.

Do you know a single project that actually adhers a common coding standard 
(outside of business projects)? I don't. It's simply not practicable. FOSS 
people follow their own style most of the cases.

> Thus, the code changes must take place both in kdevelop and kate,
> because i cannot use a katepart
> to find the indentation for files which are not opened in kdevelop,
> but part of the project. So the parsing
> in case of KDevelop must happen when the project is loaded. So i think
> this will be best implemented
> as a library (a  bunch of classes) that is used both by Kate and KDevelop.

Overkill, if at all, try to guess it from the current file your are viewing 
(see above).

> I mean to implement this. I have experience of programming in KDE, but
> no experience of the Kate or KDevelop source. So I
> am sure you developers will be able to give me valuable sugesstions /
> advice / criticism, and let me know
> if its would be a welcome and useful feature. Also, I may need help
> with the source, so help me
> out when necessary. In brief, let me know what you think of this.

Of course I'd like to see it, but you cannot reliably guess indentation 
styles. Putting .kateconfig files where appropriate is a much better (and 
simpler) approach to solve this issue.

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/20110622/944a3a0c/attachment.sig>


More information about the KDevelop-devel mailing list