Hi,
I really love the simple yet effective autocompletion using [ESC]. However, I just began to dig into Scheme, and it seems the autocompletion doesn't work with functions whose name has dashes.
For example, with the following code :
(define (a-b x) (* x x))
(define c-d 2)
If I try and type a and press [ESC], nothing happens. However, when I try with c, then the completion works. It might be a problem of the grammar.
How can I fix it ? I don't know how the grammar influences the autocompletion.
Best regards,
Louis
So, I looked a bit at the grammar definition, and I really found nothing. The selector line 248 appears to be fine :
begin = '(?x) (?<=() # preceded by ( (define)\s+ # define (() # list of parameters ([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*) ((\s+ ([[:alnum:]][[:alnum:]!$%&*+-./:<=>?@^_~]*|[._]) )* )\s* ()) '; end = '(?=))'; captures = { 1 = { name = 'keyword.control.scheme'; }; 2 = { name = 'punctuation.definition.function.scheme'; }; 3 = { name = 'entity.name.function.scheme'; }; 4 = { name = 'variable.parameter.function.scheme'; }; 7 = { name = 'punctuation.definition.function.scheme'; }; };
It is strange, because further testing gives me that with the following code :
(define (abcd-e) 2)
when I type a and press [ESC], abcd is suggested.
I read some posts from the site (http://blog.macromates.com/2012/clever-completion/ http://blog.macromates.com/2012/clever-completion/ and the corresponding manual sections), thus deducting that the variable scope affected the autocompletion and tested it by modifying the Scheme bundle to enable € in a variable name (I'm French ya know). To do that, I just modified the following code : (lines 303-315 of the grammar)
{ name = 'meta.declaration.variable.scheme'; begin = '(?<=()(define)\s([[:alnum:]][[:alnum:]€!$%&*+-./:<=>?@^_~]*)\s*.*?'; end = '(?=))'; captures = { 1 = { name = 'keyword.control.scheme'; }; 2 = { name = 'variable.other.scheme'; }; }; patterns = ( { include = '#comment'; }, { include = '#sexp'; }, { include = '#illegal'; }, ); },
And it worked !
If I type : (define ab-cd€ 23) ab And press [esc], then the whole name appears. Nevertheless, if I try with ab-, then the completion doesn't trigger. So far I experienced, I works only after alphanumeric characters.
Thus, there are two strange behaviours :
1. The entity scopes don't seem to affect autocompletion. Then, what is the recommended manner to solve my main issue ? Can I capture the function name in both selectors (entity and variable) ? 2. Why can't the autocompletion be triggered after a non alphanumeric character ?
Kind regards,
Louis
Le 10 juil. 2016 à 11:49, Louis Abraham louis.abraham@polytechnique.edu a écrit :
Hi,
I really love the simple yet effective autocompletion using [ESC]. However, I just began to dig into Scheme, and it seems the autocompletion doesn't work with functions whose name has dashes.
For example, with the following code :
(define (a-b x) (* x x))
(define c-d 2)
If I try and type a and press [ESC], nothing happens. However, when I try with c, then the completion works. It might be a problem of the grammar.
How can I fix it ? I don't know how the grammar influences the autocompletion.
Best regards,
Louis
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
On 10 Jul 2016, at 13:53, Louis Abraham wrote:
If I type : (define ab-cd€ 23) ab And press [esc], then the whole name appears. Nevertheless, if I try with ab-, then the completion doesn't trigger. So far I experienced, I works only after alphanumeric characters.
Thus, there are two strange behaviours :
- The entity scopes don't seem to affect autocompletion. Then, what
is the recommended manner to solve my main issue ? Can I capture the function name in both selectors (entity and variable) ?
What you can do is set a characterClass for the entity scope.
For example in the bundle editor create a new settings item and make the scope selector be `entity.name.function.scheme` and the actual value something like: `{ characterClass = 'variable'; }`.
Now TextMate will treat all contiguous characters matched as `entity.name.function.scheme` as a single word for the purpose of word selection, completion, etc.
- Why can't the autocompletion be triggered after a non alphanumeric
character ?
This is because TextMate only completes “words”, however, as you can define what constitute a word, you can include the dash.
For example if you do the above setting then escape will complete _if_ the dash is used in a place where it is matched as `entity.name.function.scheme`.
There is also the ability to simply make the dash a word character for the `source.scheme` scope, this would also be done by a bundle setting but one that is scoped to `source.scheme` and contains `{ wordCharacters = '-'; }`.
Thanks you a lot, finally I just used the wordCharacters trick, which is far more logical !
Le 11 juil. 2016 à 15:29, Allan Odgaard <mailinglist@textmate.org mailto:mailinglist@textmate.org> a écrit :
On 10 Jul 2016, at 13:53, Louis Abraham wrote:
If I type : (define ab-cd€ 23) ab And press [esc], then the whole name appears. Nevertheless, if I try with ab-, then the completion doesn't trigger. So far I experienced, I works only after alphanumeric characters.
Thus, there are two strange behaviours :
- The entity scopes don't seem to affect autocompletion. Then, what is the recommended manner to solve my main issue ? Can I capture the function name in both selectors (entity and variable) ?
What you can do is set a characterClass for the entity scope.
For example in the bundle editor create a new settings item and make the scope selector be entity.name.function.scheme and the actual value something like: { characterClass = 'variable'; }.
Now TextMate will treat all contiguous characters matched as entity.name.function.scheme as a single word for the purpose of word selection, completion, etc.
- Why can't the autocompletion be triggered after a non alphanumeric character ?
This is because TextMate only completes “words”, however, as you can define what constitute a word, you can include the dash.
For example if you do the above setting then escape will complete if the dash is used in a place where it is matched as entity.name.function.scheme.
There is also the ability to simply make the dash a word character for the source.scheme scope, this would also be done by a bundle setting but one that is scoped to source.scheme and contains { wordCharacters = '-'; }.
textmate mailing list textmate@lists.macromates.com mailto:textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate http://lists.macromates.com/listinfo/textmate
On 2016-07-10 11:49, Louis Abraham wrote:
Hi,
I really love the simple yet effective autocompletion using [ESC]. However, I just began to dig into Scheme, and it seems the autocompletion doesn't work with functions whose name has dashes.
For example, with the following code :
(define (a-b x) (* x x)) (define c-d 2)
If I try and type a and press [ESC], nothing happens. However, when I try with c, then the completion works. It might be a problem of the grammar.
How can I fix it ? I don't know how the grammar influences the autocompletion.
I think the two first entries of the FAQ [1] is related to this.
[1] https://github.com/textmate/textmate/wiki/FAQ