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

List:       kwrite-devel
Subject:    Re: Indenting based on syntax information already available (patch)
From:       "Robin Pedersen" <robinpeder () gmail ! com>
Date:       2008-06-06 22:09:23
Message-ID: op.ucck5xpb9lgty9 () lenobin
[Download RAW message or body]

On Thu, 05 Jun 2008 21:31:17 +0200, Dominik Haumann <dhdev@gmx.de> wrote:

> On Thursday 05 June 2008, Robin Pedersen wrote:
>> On Mon, 05 May 2008 15:26:38 +0200, Robin Pedersen
>>
>> <robin.pedersen@runbox.com> wrote:
>> > So here's what I suggest:
>> >
>> > It should be possible in an indent script to specify a syntax
>> > description file to be loaded and used in the context of the script.
>> > This can be defined in the script, just like "triggerCharacters":
>> >
>> > var triggerCharacters = "[]{}";
>> > var syntaxFormat = "ruby";
>> >
>> > When this is included in an indent script, it's guaranteed that
>> > functions like "document.attribute()" use the "ruby" syntax
>> > description. I see two possible ways to implement this:
>> >
>> > 1. When using this indenter, only "ruby" or "none" syntax highlighing
>> > is available. If another highlighing type is selected, the indenting  
>> is
>> > switched off.
>> >
>> > 2. If a different highlighing type is used, kate must load two syntax
>> > files, and use one for highlighting and one for indenting.
>> >
>> > What do you think?
>>
>> Here's a patch (unfinished prototype) that implements this.
>>
>> It works like this:
>>
>> A syntax highlighter specifies which "style" it provides through an  
>> extra
>> argument in the root xml element, e.g:
>>
>> <language name="Ruby" ... style="ruby" ...>
>>
>> For languages like C/C++/Java, there can be more than one highlight mode
>> that provides the same "style". These should be equivalent when it comes
>> to the attributes used in indent scripts.
>>
>> If an indent script requires a certain "style" (if it's using any
>> attributes from the highlighting), it must specify the style in the
>> header, e.g.:
>>
>> /** kate-script
>>   * name: Ruby
>>   * type: indentation
>>   * required-syntax-style: ruby
>>   * ...
>>
>> The attached patch reads these parameters, and disables the indenter in
>> the Tools menu if it requires a style that is different from the
>> currently selected.
>>
>> The patch is incomplete because it only disables the menu items. It
>> doesn't prevent the indenter from being selected in other ways like
>> "set-indent-mode", "kate: indent-mode". It doesn't disable the indenter
>> if the highlighting is changed after it has been activated.
>>
>> However, I think it demonstrates the design enough for you to give some
>> feedback.
>
> At the Kate developer sprint we also talked about how Kate should decide
> which indenter can indent which languages. We came up with
>   * the script header should state which hl-modes it can indent
>     (instead of mimetype/wildcard in the header)
>
> Your patch meets that requirement with the mapping indent-script ->
> required-syntax-style <-> style <- highlighting.xml
>
> So I think it's a good idea. A highlighting can then be indented by  
> multiple
> indenters, and every indenter has the carma to indent several  
> highlightings
>
> So +1 from my side for this approach.
>
> Do we miss anything? :)
>
> Dominik

So, is this something that can be added in current trunk (isn't there a  
feature freeze), or do it have to wait until 4.1.1 or 4.2 ?

-- 
Robin Pedersen
_______________________________________________
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