I'd like my functions to appear in the popup menu. My function definitions look like this:
(define (func-name arg1 arg2) (print "the arguments were " arg1 " and " arg2))
and the bundle I've been given has this:
{ name = 'declaration.function.lisp'; match = '(\b(?i:(def-new|define(-macro)?))\b)(\s+)((\w|-|!|?)*)'; captures = { 2 = { name = 'keyword.control.function-type.lisp'; }; 4 = { name = 'entity.name.function.lisp'; }; }; },
I can understand why it also covers other types of definition ( eg (def-new and (define-macro ) although I rarely use these, and it sort of looks Ok at first glance (I don't know whether some of those parentheses should be escaped...). Nothing appears in the function pop-up menu, though. Should I expect this to work as like this or has something else gone wrong, or does it rely on other things being set as well?
On Jul 29, 2006, at 9:14 AM, cormullion@mac.com wrote:
I'd like my functions to appear in the popup menu. My function definitions look like this:
http://www.macromates.com/textmate/manual/ navigation_overview#customizing_the_list
A new preference item is what you want:
{ showInSymbolList = 1; }
With a scope of whatever you want in the list.
On 29/7/2006, at 16:14, cormullion@mac.com wrote:
{ name = 'declaration.function.lisp'; match = '(\b(?i:(def\-new|define(-macro)?))\b)(\s+)((\w|\-|\!|\?)
*)'; captures = { 2 = { name = 'keyword.control.function-type.lisp'; }; 4 = { name = 'entity.name.function.lisp'; }; }; },
I can understand why it also covers other types of definition ( eg (def-new and (define-macro ) although I rarely use these, and
[...] it sort of looks Ok at first glance
Well, try put your regexp in the normal find dialog, click Regular Expression and do a Next -- for me it only matches the ‘define’ part.
(I don't know whether some of those parentheses should be escaped...)
All those you want to match literally should be escaped.
[...] Should I expect this to work as like this or has something else gone wrong, or does it rely on other things being set as well?
It does rely on the preference Michael Sheets mentioned, but entity.name.function should already be set to show in the pop-up.
The problem is with your regexp to match the defines. You can also use ⌃⇧P to see the scope of the caret when debugging this.
On 2006-07-29, at 19:12, Allan Odgaard wrote:
Well, try put your regexp in the normal find dialog, click Regular Expression and do a Next -- for me it only matches the ‘define’ part.
Thanks. You're right, it doesn't work like it should on a document...
(I don't know whether some of those parentheses should be escaped...)
All those you want to match literally should be escaped.
Definitely! And I've got to work out how to match any number of arguments, each of which can contain any character except " ' ( ) : , and space, but mustn't start with # ; " ' ( ) { } . , 0 1 2 3 4 5 6 7 8 9. I'll have to go back to regexp school, i think. :-)
It does rely on the preference Michael Sheets mentioned, but entity.name.function should already be set to show in the pop-up.
Yes, thanks to you and Michael for helping. There is some light at the end of the tunnel...
On 30/7/2006, at 1:13, cormullion@mac.com wrote:
Definitely! And I've got to work out how to match any number of arguments, each of which can contain any character except " ' ( ) : , and space, but mustn't start with # ; " ' ( ) { } . , 0 1 2 3 4 5 6 7 8 9. I'll have to go back to regexp school, i think. :-)
Something like: (?![#;"'(){}.,0-9])[^"'(): ]+
First a negative look-ahead on what you can’t match (so only applies to first char,) and then the characters valid in an argument (using a negative character class.)
You need to escape one set of the quotes when using it in the language grammar (where ' is escaped by using ''.)
On 2006-07-31, at 00:12, Allan Odgaard wrote:
On 30/7/2006, at 1:13, cormullion@mac.com wrote:
Definitely! And I've got to work out how to match any number of arguments, each of which can contain any character except " ' ( ) : , and space, but mustn't start with # ; " ' ( ) { } . , 0 1 2 3 4 5 6 7 8 9. I'll have to go back to regexp school, i think. :-)
Something like: (?![#;"'(){}.,0-9])[^"'(): ]+
Thanks, Allan. Your help is appreciated - I'm finding this quite tricky! ;-)
I've got the idea of matching the names, but now I'm trying to work out how to match the shape of possible function definitions. Assuming temporarily that names are just [a-z]*, I'm trying to match:
(define (func) (define (fun arg1) (define (func arg1 arg2) (define (func arg1 arg2 arg3)
I can find these patterns with:
((define)(\s+)((\w+\s*)+())
but I can't successfully capture a variable number of arguments for use with 'capture'?
The rest of TextMate is looking very nice.... ;-)
On 3/8/2006, at 11:05, cormullion@mac.com wrote:
I've got the idea of matching the names, but now I'm trying to work out how to match the shape of possible function definitions. Assuming temporarily that names are just [a-z]*, I'm trying to match:
(define (func) (define (fun arg1) (define (func arg1 arg2) (define (func arg1 arg2 arg3)
I can find these patterns with:
((define)(\s+)((\w+\s*)+())
but I can't successfully capture a variable number of arguments for use with 'capture'?
No, that is not possible, as regexp captures will only capture the last repeat.
In this case you would change the rule to using begin/end, like:
{ name = 'meta.function.newlisp'; begin = '((define)\s+('; beginCaptures = { 1 = { name = 'keyword.control.define.newlisp'; }; }; end = ')'; patterns = ( { name = 'variable.parameter.newlisp'; match = '[a-z]+'; } ); }
On 2006-08-03, at 13:48, Allan Odgaard wrote:
In this case you would change the rule to using begin/end, like:
{ name = 'meta.function.newlisp'; begin = '((define)\s+('; beginCaptures = { 1 = { name = 'keyword.control.define.newlisp'; }; }; end = ')'; patterns = ( { name = 'variable.parameter.newlisp'; match = '[a-z]+'; } ); }
Hey - I got it working, and merged your two previous suggestions to produce a working (but hard-to-read) language definition. Eventually. ;-)
Thank you so much for your patience...
Hey - I got it working, and merged your two previous suggestions to produce a working (but hard-to-read) language definition. Eventually. ;-)
Thank you so much for your patience...
Just one quirk I noticed: when I quit TextMate and re-opened it, these functions didn't appear. But I changed the bundle property to this value:
showInSymbolList = 0;
and now functions work every time, and continue to work over relaunches. The manual clearly states that this should = 1, yet only 0 works for me. I've managed to reverse the polarity somehow. I'm sure there's an explanation, if not a simple one... :-)
thanks
On 3/8/2006, at 21:39, cormullion@mac.com wrote:
Just one quirk I noticed: when I quit TextMate and re-opened it, these functions didn't appear. But I changed the bundle property to this value:
showInSymbolList = 0;
and now functions work every time, and continue to work over relaunches. The manual clearly states that this should = 1, yet only 0 works for me. I've managed to reverse the polarity somehow. I'm sure there's an explanation, if not a simple one... :-)
Most likely you did not specify the proper scope selector.
E.g. if you gave no scope selector, ‘ = 1’ would make the entire document go into the symbol pop-up (but TM would not do that, thus showing nothing) -- setting it to ‘ = 0’ would then exclude the entire document, except there are more targeted preferences for function names already, so these would still appear.
I.e. just remove the preference entirely, and I believe it should work as it currently does.
On 2006-08-04, at 16:37, Allan Odgaard wrote:
On 3/8/2006, at 21:39, cormullion@mac.com wrote:
Just one quirk I noticed: when I quit TextMate and re-opened it, these functions didn't appear. But I changed the bundle property to this value:
showInSymbolList = 0;
and now functions work every time, and continue to work over relaunches. The manual clearly states that this should = 1, yet only 0 works for me. I've managed to reverse the polarity somehow. I'm sure there's an explanation, if not a simple one... :-)
Most likely you did not specify the proper scope selector.
E.g. if you gave no scope selector, ‘ = 1’ would make the entire document go into the symbol pop-up (but TM would not do that, thus showing nothing) -- setting it to ‘ = 0’ would then exclude the entire document, except there are more targeted preferences for function names already, so these would still appear.
I.e. just remove the preference entirely, and I believe it should work as it currently does.
Thanks - I did it! I tried using meta.function.newlisp as the scope selector and it now works. Before I'd been using source.newlisp.
I appreciate your help! You must find it frustrating that some of us are mad enough to not use the languages and bundles provided yet not smart enough to work out how to make new language bundles for ourselves... :-)