[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Re: Automatic indentation-detection in Kate and KDevelop
From:       Tirtha Chatterjee <tirtha.p.chatterjee () gmail ! com>
Date:       2011-06-23 17:58:46
Message-ID: BANLkTik2qHW+Vi9fqq7td7CRcMJucvuPmQ () mail ! gmail ! com
[Download RAW message or body]

On Thu, Jun 23, 2011 at 9:23 PM, Erlend Hamberg <ehamberg@gmail.com> wrote:
> On 23 June 2011 17:33, Christoph Cullmann <cullmann@absint.com> wrote:
>> I think that might be an extension to the indenter scripts we have atm.
>> If the user has set this "auto detect" setting, for a new opened file an extra
>> function would be called for the indenter, like detectIndentation or how ever.
>>
>> Problem is where to store the found settings.
>> Guess a simple key/value storage per document would be needed, then.
>
> Not sure this is needed. At least for the single document scenario. In
> Vim I use a simple, “dumb” heuristic that simply looks at a number of
> lines, check how much they are indented compared to the line before and
> whether tabs or spaces are used. It is of course simple to think up
> scenarios where this will fail, but in practice it works really well.
>
> So if a function in a script file could be run automatically when a
> document is opened, a simple function could simply look at the first 100
> (or whatever) lines and then guess settings for indentation width,
> whether to expand tabs to spaces and. If the results are too ambiguous
> or the file is empty, the default values can be used.
This is exactly what I have in mind. Look at a max N lines (N is a
predefined const),
and prepare statistics, and based on that return the found values, along with a
percentage of accuracy. If accuracy is below a certain mark, we
fallback to default settings.
How does this sound?
>
> --
> Erlend Hamberg
> ehamberg@gmail.com
> _______________________________________________
> KWrite-Devel mailing list
> KWrite-Devel@kde.org
> https://mail.kde.org/mailman/listinfo/kwrite-devel
>



-- 
Tirtha Chatterjee
KDE developer
http://wyuka.co.cc/
_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic