Redefining Word Characters via OakWordCharacters

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Redefining Word Characters via OakWordCharacters

Bastien Dejean
Hi,

I would like to be able to redefine which characters constitute a word inside a bundle.
I was wondering if the following approach might worth the try :

– create a shell variable inside the bundle called TM_WORD_CHARACTERS ;
– replace (using jr_swizzleMethod) the isWordCharacter method of the OakWordCharacters class : if the above variable don't exist call the original method.

(I'm not very fluent in Objective-C (^_^).)

Thanks.

_______________________________________________
textmate-plugins mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate-plugins
Reply | Threaded
Open this post in threaded view
|

Re: Redefining Word Characters via OakWordCharacters

Allan Odgaard-4
On 26 May 2010, at 16:57, Bastien Dejean wrote:

> I would like to be able to redefine which characters constitute a  
> word inside a bundle.
> I was wondering if the following approach might worth the try : [...]
>
> – create a shell variable inside the bundle called  
> TM_WORD_CHARACTERS ;
> – replace (using jr_swizzleMethod) the isWordCharacter method of the  
> OakWordCharacters class : if the above variable don't exist call the  
> original method.

I doubt this would work well — it is however a known request and  
something which I’ll likely support in the future.

My idea for how to support it is to have bundles be able to specify a  
character “type” for a scope (like with other scoped preferences).

A type is simply a string with some predefined values (like ‘word’,  
‘punctuation’, and ‘whitespace’) but it can effectively be anything.

This way a grammar can match e.g. “\d+(\.\d+){3}” (IP address) and set  
the type either to ‘word’ or simply ‘ip-address’ and TM will treat it  
as a single unit when double-clicking or moving caret with the option  
key.

Anyway… just what I have been pondering — I know this request is big  
with Gerd, not sure if he is on this list and wants to comment.

Also don’t know if this will suffice for your lisp bundle as I didn’t  
understand if ‘char=/’ was one unit or it means something else?


_______________________________________________
textmate-plugins mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate-plugins
Reply | Threaded
Open this post in threaded view
|

Re: Redefining Word Characters via OakWordCharacters

Gerd Knops-2

On May 26, 2010, at 10:26 AM, Allan Odgaard wrote:

> On 26 May 2010, at 16:57, Bastien Dejean wrote:
>
>> I would like to be able to redefine which characters constitute a word inside a bundle.
>> I was wondering if the following approach might worth the try : [...]
>>
>> – create a shell variable inside the bundle called TM_WORD_CHARACTERS ;
>> – replace (using jr_swizzleMethod) the isWordCharacter method of the OakWordCharacters class : if the above variable don't exist call the original method.
>
> I doubt this would work well — it is however a known request and something which I’ll likely support in the future.
>
> My idea for how to support it is to have bundles be able to specify a character “type” for a scope (like with other scoped preferences).
>
> A type is simply a string with some predefined values (like ‘word’, ‘punctuation’, and ‘whitespace’) but it can effectively be anything.
>
> This way a grammar can match e.g. “\d+(\.\d+){3}” (IP address) and set the type either to ‘word’ or simply ‘ip-address’ and TM will treat it as a single unit when double-clicking or moving caret with the option key.
>
> Anyway… just what I have been pondering — I know this request is big with Gerd, not sure if he is on this list and wants to comment.
>
What do you want me to say other than I hope the future hurries up and gets here? ;-)

The above seems like a very powerful approach to me. Seems to work for all cases I can think of right now, and a per-scope rule is infinitely more flexible than a per language setting of word characters.

Gerd


> Also don’t know if this will suffice for your lisp bundle as I didn’t understand if ‘char=/’ was one unit or it means something else?
>
>
> _______________________________________________
> textmate-plugins mailing list
> [hidden email]
> http://lists.macromates.com/listinfo/textmate-plugins

_______________________________________________
textmate-plugins mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate-plugins
Reply | Threaded
Open this post in threaded view
|

Re: Redefining Word Characters via OakWordCharacters

Bastien Dejean
In reply to this post by Allan Odgaard-4
Le 26 mai 2010 à 17:26, Allan Odgaard a écrit :

> On 26 May 2010, at 16:57, Bastien Dejean wrote:
>
>> I would like to be able to redefine which characters constitute a word inside a bundle.
>> I was wondering if the following approach might worth the try : [...]
>>
>> – create a shell variable inside the bundle called TM_WORD_CHARACTERS ;
>> – replace (using jr_swizzleMethod) the isWordCharacter method of the OakWordCharacters class : if the above variable don't exist call the original method.
>
> I doubt this would work well — it is however a known request and something which I’ll likely support in the future.

Isn't the ‘TM_CURRENT_WORD’ variable built using ‘isWordCharacter’ ?
Could, at least, the autocompletion work “well” ?

> My idea for how to support it is to have bundles be able to specify a character “type” for a scope (like with other scoped preferences).
>
> A type is simply a string with some predefined values (like ‘word’, ‘punctuation’, and ‘whitespace’) but it can effectively be anything.
>
> This way a grammar can match e.g. “\d+(\.\d+){3}” (IP address) and set the type either to ‘word’ or simply ‘ip-address’ and TM will treat it as a single unit when double-clicking or moving caret with the option key.

Seems quite powerful.

> Also don’t know if this will suffice for your lisp bundle

It might if it's properly linked to autocompletion.

> as I didn’t understand if ‘char=/’ was one unit or it means something else?

‘char/=’ is the name of a Common Lisp function.
The following characters are authorized in function names: +-*/<=>

_______________________________________________
textmate-plugins mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate-plugins