[TxMt] Re: Autocompletion of variables using dashes

Louis Abraham louis.abraham at polytechnique.edu
Sun Jul 10 11:53:38 UTC 2016


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 at 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 at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20160710/e3f83462/attachment-0001.html>


More information about the textmate mailing list