Automatic indentation-detection in Kate and KDevelop

Tirtha Chatterjee tirtha.p.chatterjee at gmail.com
Tue Jun 21 23:56:12 UTC 2011


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.

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.

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.

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.

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.

--
Tirtha Chatterjee
KDE developer
http://wyuka.co.cc/




More information about the KDevelop-devel mailing list