Hi Adam,
Thank you for your answer. The thing is that the function name is arbitrary(determined by the programmer just like freely named variables)
I can define a function with:
function xyz_any_function_name ...code end function
The word function and end function are defined as reserved keywords and as such get a color blue(or whatever)
What I was hoping to have is have the arbitrary name of the function "xyz_any_function_name" have a color red when it's defined(after the word "function") or when it's called(after the word "call".
Is that possible?
Thanks John
________________________________ From: Adam Strzelecki ono@java.pl To: John Relosa john.relosa@yahoo.com; TextMate users textmate@lists.macromates.com Sent: Thursday, December 29, 2011 8:55 AM Subject: Re: [TxMt] Coloring for a function call
How would I make it so the "my_function_name" has a different color after the "call" keyword ?
I guess you need to group the function name via your lang grammar regular expression and assign some scope to it like "support.function.any-method.yourlang", similar way as you already do keyword scope assign for `call`.
By default themes expect "support.function" scope prefix for standard built-in functions (like time() free() malloc() for C), and "support.function.any-method" prefix for other non-standard, non-built in, user defined functions.
Regards, - Adam Strzelecki
Message: 9 Date: Wed, 28 Dec 2011 08:45:02 -0800 (PST) From: John Relosa john.relosa@yahoo.com To: "textmate@lists.macromates.com" textmate@lists.macromates.com Subject: [TxMt] Coloring for a function call Message-ID: 1325090702.17456.YahooMailNeo@web121902.mail.ne1.yahoo.com Content-Type: text/plain; charset="iso-8859-1"
Hello,
I am trying to create a bundle where in the particular language after a function definition you would call that function with:
[code....]
function my_function_name . . code
. . end function
...more code...
call my_function_name
[/code....]
Now for the question to the TxMt gurus:
How would I make it so the "my_function_name" has a different color after the "call" keyword ??
I have already made the "call" to be a reserved keyword colored blue but if would be nice to have the "my_function_name" function colored red or some other catchy color after the word "call"
Is that possible and what would be the syntax for the bundle?
Thanks in advance.
John
On 29 Dec 2011, at 18:18, John Relosa wrote:
What I was hoping to have is have the arbitrary name of the function "xyz_any_function_name" have a color red when it's defined(after the word "function") or when it's called(after the word "call".
Hi,
maybe try something like (AN EXAMPLE!):
{ name = 'meta.call.your_LG'; match = '^\s*(call)\s+(\S+)'; captures = { 1 = { name = 'keyword.control.your_LG'; }; 2 = { name = 'entity.name.type.call.your_LG'; }; }; }, { name = 'meta.function.your_LG'; match = '^\s*(function)\s+(\S+)'; captures = { 1 = { name = 'storage.type.function.your_LG'; }; 2 = { name = 'entity.name.function.your_LG'; }; }; },
If you assign the same name for the 2. match in 'call' and 'function' or you write (function|call) the function name will appear in the same colour.
And look in other Language Grammars (C, Ruby, Python, ...) since it's a common task.
Hope it helps a bit.
Best, --Hans
Hi Hans,
Thanks for your reply, getting closer :-)
The one for call works great as it's never in the beginning of a line and there is always space before so this works: {name = 'meta.call.my_LG'; match = '\s*(call)\s+((\w+)\w*)'; captures = { 1 = { name = 'keyword.control.my_LG'; }; 2 = { name = 'entity.name.call.my_LG'; }; }; },
I cannot make it to work for the function though which is always in the beginning of a line with no space before it. I removed the \s* and replaced it with the ^ start of line anchor but it does not seem to work: {name = 'meta.function.my_LG'; match = '^(function)\s+((\w+)\w*)'; captures = { 1 = { name = 'keyword.control.my_LG'; }; 2 = { name = 'entity.name.function.my_LG'; }; }; },
What am I doing wrong?
Thanks.
________________________________ From: Hans-Jörg Bibiko bibiko@eva.mpg.de To: John Relosa john.relosa@yahoo.com; TextMate users textmate@lists.macromates.com Sent: Thursday, December 29, 2011 9:50 AM Subject: Re: [TxMt] Re: Coloring for a function call
On 29 Dec 2011, at 18:18, John Relosa wrote:
What I was hoping to have is have the arbitrary name of the function "xyz_any_function_name" have a color red when it's defined(after the word "function") or when it's called(after the word "call".
Hi,
maybe try something like (AN EXAMPLE!):
{ name = 'meta.call.your_LG'; match = '^\s*(call)\s+(\S+)'; captures = { 1 = { name = 'keyword.control.your_LG'; }; 2 = { name = 'entity.name.type.call.your_LG'; }; }; }, { name = 'meta.function.your_LG'; match = '^\s*(function)\s+(\S+)'; captures = { 1 = { name = 'storage.type.function.your_LG'; }; 2 = { name = 'entity.name.function.your_LG'; }; }; },
If you assign the same name for the 2. match in 'call' and 'function' or you write (function|call) the function name will appear in the same colour.
And look in other Language Grammars (C, Ruby, Python, ...) since it's a common task.
Hope it helps a bit.
Best, --Hans
Hello and Happy New Year!
Does any of the TxMt gurus know why the below does not work?
Message: 5 Date: Thu, 29 Dec 2011 11:27:01 -0800 (PST) From: John Relosa john.relosa@yahoo.com To: textmate textmate@lists.macromates.com Subject: [TxMt] Re: Coloring for a function call Message-ID: 1325186821.60244.YahooMailNeo@web121902.mail.ne1.yahoo.com Content-Type: text/plain; charset="iso-8859-1"
Hi Hans,
Thanks for your reply, getting closer :-)
The one for call works great as it's never in the?beginning?of a line and there is always space before so this works:
{name = 'meta.call.my_LG'; match = '\s*(call)\s+((\w+)\w*)'; captures = { 1 = { name = 'keyword.control.my_LG'; }; 2 = { name = 'entity.name.call.my_LG'; }; }; },
I cannot make it to work for the function though which is always in the beginning of a line with no space before it.
I removed the \s* and replaced it with the ^ (start of line anchor) but it does NOT seem to work:
{name = 'meta.function.my_LG'; match = '^(function)\s+((\w+)\w*)'; captures = { 1 = { name = 'keyword.control.my_LG'; }; 2 = { name = 'entity.name.function.my_LG'; }; }; },
What am I doing wrong?
Thanks.
________________________________ From: Hans-Jörg Bibiko bibiko@eva.mpg.de To: John Relosa john.relosa@yahoo.com; TextMate users textmate@lists.macromates.com Sent: Thursday, December 29, 2011 9:50 AM Subject: Re: [TxMt] Re: Coloring for a function call
On 29 Dec 2011, at 18:18, John Relosa wrote:
What I was hoping to have is have the arbitrary name of the function "xyz_any_function_name" have a color red when it's defined(after the word "function") or when it's called(after the word "call".
Hi,
maybe try something like (AN EXAMPLE!):
{ name = 'meta.call.your_LG'; match = '^\s*(call)\s+(\S+)'; captures = { 1 = { name = 'keyword.control.your_LG'; }; 2 = { name = 'entity.name.type.call.your_LG'; }; }; }, { name = 'meta.function.your_LG'; match = '^\s*(function)\s+(\S+)'; captures = { 1 = { name = 'storage.type.function.your_LG'; }; 2 = { name = 'entity.name.function.your_LG'; }; }; },
If you assign the same name for the 2. match in 'call' and 'function' or you write (function|call) the function name will appear in the same colour.
And look in other Language Grammars (C, Ruby, Python, ...) since it's a common task.
Hope it helps a bit.
Best, --Hans