Dear all,
The R bundle for Avian/TM2 seems to have lost the (neat) ability to add and move to an indented new line after typing an open brace followed by Enter. That is, going from
{.}
to
{ . }
by typing Enter (dot indicates caret). I got used to this in TM1 and it saved countless little bits of time, so I'd like to get it back. I see that it works in C, so obviously it can be done with TM2, but I'm not sure what change I need to make to the R bundle to get it working again. Any pointers would be gratefully received...
While I'm on the topic, it would be nice if standalone "if" statements produced indentation on the next line (again as in the C scope), so that I can write R code like
if (x < 0) x <- abs(x)
without having to indent the second line manually (and then unindent the line following it). This has never happened with the Textmate R bundle, so perhaps Hans-Jörg could take it as a feature request... ;) I assume it's a matter of tweaking the language grammar.
All the best, Jon
This is also an issue for PHP. How do you go about fixing these things? I assume it's somewhere in the Syntaxes/PHP.plist file, but it's huge and I'm finding it difficult to work out what I'm supposed to change in there to get this back.
Cheers, George.
On 9 Jan 2012, at 15:31, Jon Clayden wrote:
Dear all,
The R bundle for Avian/TM2 seems to have lost the (neat) ability to add and move to an indented new line after typing an open brace followed by Enter. That is, going from
{.}
to
{ . }
by typing Enter (dot indicates caret). I got used to this in TM1 and it saved countless little bits of time, so I'd like to get it back. I see that it works in C, so obviously it can be done with TM2, but I'm not sure what change I need to make to the R bundle to get it working again. Any pointers would be gratefully received...
While I'm on the topic, it would be nice if standalone "if" statements produced indentation on the next line (again as in the C scope), so that I can write R code like
if (x < 0) x <- abs(x)
without having to indent the second line manually (and then unindent the line following it). This has never happened with the Textmate R bundle, so perhaps Hans-Jörg could take it as a feature request... ;) I assume it's a matter of tweaking the language grammar.
All the best, Jon
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
This is also an issue for PHP.
I'm finding that as well. Any pointers gratefully received.
It has to do something with bundle settings/grammar as {↩} works perfectly well in C/C++ bundle.
I also find TM2 R bundle to work horribly slow for autocompletion. Like 5-10 seconds when ^.
On 11 Jan 2012, at 14:15, Adam Strzelecki wrote:
I also find TM2 R bundle to work horribly slow for autocompletion. Like 5-10 seconds when ^.
Hi,
I'll wait a bit to update the R bundles incl support for TM2 since I'm rather busy and I do not know what Allan will change for the first official TM2 release.
Due to completion, well, this is the R code which will be executed
TM_RdaemongetCompletionList <- function(x,ic=F) { invisible(help.search("^§!#%$"));db<-utils:::.hsearch_db() a<-db$Alias[grep(paste("^",x,sep=""),db$Alias[,1],ignore.case=ic,perl=T),c(1,3)] if(is.null(dim(a))) {a<-matrix(a,ncol=2)} a<-a[grep("[<,]|-(class|package|method(s)?)|TM_Rdaemon",a[,1],invert=T),] if(is.null(dim(a))) {a<-matrix(a,ncol=2)} cat(sort(apply(a,1,function(x)paste(c(x[1],x[2]),collapse='\t'))),sep='\n') }
You can try e.g.
TM_RdaemongetCompletionList('q')
Only the first invocation could be a bit slower if the TM R helper daemon does not yet run.
Cheers, --Hans
You can try e.g. TM_RdaemongetCompletionList('q')
Hmm… I've reinstalled R to 2.14.1 and it works it works quick as expected.
Maybe also I got wrong impression it's slow, but it just tends to jam in TM2. i.e.:
(1) type plot( (2) press ^,
Parameters popup menu won't appear until you press other key.
Also ^. keeps working weird if: (1) type plot (2) press ^. (3) delete everything with ⌫ (delete) (4) "plot" autocompletion reappears, but there's no word at all
Only the first invocation could be a bit slower if the TM R helper daemon does not yet run.
It is pretty amazing contraption, I guess it is most advanced completion of all TM bundles.
Cheers,
On Jan 9, 2012, at 9:31 AM, Jon Clayden wrote:
The R bundle for Avian/TM2 seems to have lost the (neat) ability to add and move to an indented new line after typing an open brace followed by Enter. That is, going from
I've answered this question a few times elsewhere so I figured a detailed explaination is in order:
In TM1 the behavior of the return key when it was between {} was hardcoded and only worked for those specific characters. It also had the major downside that you couldn't override it's behavior when the characters weren't special.
So in 2.0 there is now a snippet¹ with a very specific scope:
source & ((L:punctuation.section.*.begin & R:punctuation.section.*.end) | (L:punctuation.definition.*.begin & R:punctuation.definition.*.end)) - string
In short this means it works only in source files, when the caret is between two specific punctuation scopes, with the special exclusion of strings. This means that is can work with any set of characters, even cases where the begin/end are multiple characters. And this works without a special 'this is empty' scope that had to be used to get this behavior in 1.x.
The downside is that the characters must be matched and given a proper scope for this to work. As you've seen it works in the C languages because they match all block cases and give the proper scopes to the punctuation. In some languages it can be impossible to full match blocks, and in others the grammar just doesn't do so currently.
So the fix is to either start scoping blocks, or if that's not possible the grammar can specially match empty cases so the scopes at least exist there. If you have any questions on how to do this you can see me on IRC for help (username: Infininight).
¹ The snippet is "Return Inside Empty Item" inside the Source bundle.
Thanks for the info, Michael - it helps a lot. I've managed to get the old behaviour back by adding this to the patterns in the R grammar:
{ begin = '{'; beginCaptures = { 0 = { name = 'punctuation.section.block.begin.r'; }; }; end = '}'; endCaptures = { 0 = { name = 'punctuation.section.block.end.r'; }; }; name = 'meta.block.r'; patterns = ( { include = 'source.r'; } ); },
Jon
On 11 January 2012 17:56, Michael Sheets mummer@whitefalls.org wrote:
On Jan 9, 2012, at 9:31 AM, Jon Clayden wrote:
The R bundle for Avian/TM2 seems to have lost the (neat) ability to add and move to an indented new line after typing an open brace followed by Enter. That is, going from
I've answered this question a few times elsewhere so I figured a detailed explaination is in order:
In TM1 the behavior of the return key when it was between {} was hardcoded and only worked for those specific characters. It also had the major downside that you couldn't override it's behavior when the characters weren't special.
So in 2.0 there is now a snippet¹ with a very specific scope:
source & ((L:punctuation.section.*.begin & R:punctuation.section.*.end) | (L:punctuation.definition.*.begin & R:punctuation.definition.*.end)) - string
In short this means it works only in source files, when the caret is between two specific punctuation scopes, with the special exclusion of strings. This means that is can work with any set of characters, even cases where the begin/end are multiple characters. And this works without a special 'this is empty' scope that had to be used to get this behavior in 1.x.
The downside is that the characters must be matched and given a proper scope for this to work. As you've seen it works in the C languages because they match all block cases and give the proper scopes to the punctuation. In some languages it can be impossible to full match blocks, and in others the grammar just doesn't do so currently.
So the fix is to either start scoping blocks, or if that's not possible the grammar can specially match empty cases so the scopes at least exist there. If you have any questions on how to do this you can see me on IRC for help (username: Infininight).
¹ The snippet is "Return Inside Empty Item" inside the Source bundle.
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate