Glad I could help. I just happened to have done this stuff about a week or two ago. Had I not, I would have been pretty clueless.

agibsonsw wrote:Off-topic: What's a straight-forward way (with the API) to position the cursor? I know I could use run_command, but..

What do you mean position the cursor...move the cursor to postion x on line y?

This is assuming you know how to calculate your new position and create a region.You usually need to account for multiselect so you would clear the current selections and then add each new selection region:

Well this works, thank you @facelessuser. Although I'm not entirely happy with my choice of colour (a sort of lilac..) but at list I achieved my aim

I'm not sure I want to pursue this any further just at the moment. I can imagine spending hours (days..) on this . I would learn a little more about regex, ST themes, and have control over colours I suppose.

Regards, Andy.

Edited: I also modified the scope from '...global.python' to 'storage.type.function.api.python' so that it should behave better, and chucked the word 'global' in with def|lambda.

Attachments

sublime_selected2.png (13.52 KiB) Viewed 1244 times

"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

@facelessuser. Sorry to bore but I've got control now without too much effort, whe'hay! I copied my new category/dictionary entry 'storage.type.function.api.python' to create 'storage.type.function.general.python', and added a few standard, and commonly used library, functions to it - see the yellow text in the screenshot. These two categories are near the front of the tmLanguage file, so conflict seems unlikely.

I was under the impression that I would need to study the whole language file to be able to slip these in . So now I can add functions as I go along, and create more categories if I so chose, whe'hay! Job done.

I might try and tackle objects like window, view.. This might prove a little trickier though, as I haven't got an opening brace '(' to latch on to

Regards, Andy.

Attachments

sublime_selected3.png (18.06 KiB) Viewed 1232 times

"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

Window and view should be targetable. In the method I am using, I catch all of the object members (even the ones without (); I just don't scope them with anything; like I said I changed it a lot of things to help me out in the future).

Can you elaborate on "I just don't scope them with anything" please? This should help me..

This is what I was trying to say earlier. I already accounted for all of the stuff, so I was suggesting that you leverage the work I already did.Basically in my version I don't do this (?:[a-zA-Z_][a-zA-Z0-9_]*\.)*. This will greedily include any parent object that happens to come before your target. That is the way it was doing things before I touched it. If an object had a function in it, all preceding object members got pulled into the scope which I though overzealous. So what I did is change the default function check to not greedily include those members, and then I catch them with this and give them no additional scope (I should probably check for lists here as well):

So you can see here I look for built in things first, and if I don't find those, I throw out all the dot members that aren't function calls etc, then I check for API and then functions, and then lists etc.:

@facelessuser. What seems to be relatively straight-forward is getting complicated . Part of my confusion was/is that even though I use a non-capturing group (?: ), it seems that the more general term 'function' later on collects this text.

It also seems odd that only the word 'self' gets caught out, although I think 'key' has also lost its colour, and (possibly) index.

So changing the key 'captures' to 'match' is not likely to help me? And you wouldn't recommend that I ditch the name-part 'function' all-together? Edited: Ignore this remark about 'function' - I realise this wouldn't help (it IS a function, regardless).

I apologise . I should be studying all the content you have supplied me with in great depth, but I'm still taking pigeon steps at the mo. I could just "borrow" your language file, but I'm a bit obstinate

"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

agibsonsw wrote:I apologise . I should be studying all the content you have supplied me with in great depth, but I'm still taking pigeon steps at the mo. I could just "borrow" your language file, but I'm a bit obstinate

It is what makes us programmers. Early on with javascript, I wrote my own simple framework (not because I thought I could do better than Jquery; I think Jquery is great and way better) but I just wanted to learn as much as I could about javascript...it was both fun and painful, but I ended up with a pretty usable framework. In the end, I think I learned more about web browsers and javascript than I ever cared to learn.

@facelessuser. Ditto. I wrote my own JavaScript library . Admittedly, some methods such as $() and getElementsByClassName() I pretty much copied letter for letter, but most methods I adapted (improved upon..), including creating my own sort procedure and date parser. I wanted to look at jQuery, but I didn't fancy reading another book. So I went on to the jQuery forum and answered tons of questions (before I'd even typed a line of jQuery code ).

Anyway, I think I've short-circuited my labours. I realised that the function greediness is how the language file behaves. I wasn't looking to correct this behaviour, merely to add a number of specific methods/terms to the language. And it's mainly the term 'self' that was an issue (the word 'key' isn't even in the file!).

For the moment I've added the terms self and cls in with global, very near the top of the file. The screenshot shows that self, and my api calls, are colour-coded . If the function scope gobbles up other terms then that's SEP! [Actually, placing 'self' near the top of the file may prevent 'function' from gobbling up text anyway..]

All I need to do now (hopefully) is decide what words/methods/additional categories I want and flatten out the colours a bit.

Regards, and thanks again, Andy.

Attachments

sublime_selected4.png (25.74 KiB) Viewed 1194 times

"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.