Hi,
Since I've installed the last (pre-release) version of Tinn-R, I've found that Data completion seems to work more often than it did before. However, I find it much less accurate than before, when there were separate shortcuts for function argument completion (CTRL+D) and data/list completion (CTRL+SHIFT+D). There are many problems related to completion. I've already described some of them in previous posts, but I'd like to pinpoint interactive problems due to the recent updates of the pre-release.
First, having the same shortcut for both function and list completion is confusing, because for example when I place the text cursor after a function's open parenthesis (but not directly after the "(" character), I may want to know which arguments that function requires... even if the cursor is close to some "list" object... and even if there is a "$" after that list object. If many IDE's, there are different shortcuts for both assistants: CTRL+Space for function completion, and CTRL+Shift+Space for exploring an object's subitems. Also, some IDE's display a list of these subitems automatically when the subitem symbol ("." in most languages, but "$" or more rarely "@" in R) is written (although such a feature is not mandatory at all). I think the Tinn-R completion features were probably tested to work well enough in cases where code is written linearly (I mean when the user does not go back in his code, always adding text, from left to right, top to bottom)... but not as good when the user reviews his code and wishes to make important changes there and there.
For example, when I review the following code, it's hard to know which are the function's arguments when the text cursor is away from the open parenthesis:
DF = data.frame(x=1:10, y=rnorm(n=10))
Gpars = list(col="red", lwd=2.0, pch=19L)
with(Gpars, plot(x=DF$x, y=DF$y, col=col, lwd=lwd, pch=pch))
Indeed, if the cursor is just to the right of DF$, completion assistant will show me {x, y} subitems of DF but won't tell me anything about plot function's arguments.
Second, it would be very nice if the R language punctuation were better understood by the completion features, and the objects' hierarchy as well. Why is data completion restricted to single-level-of-hierarchy objects? For example, if I have this object A and want to complete with some subitem of a2b, it does not work. On the contrary, in R console, it works at any level of object hierarchy...
A <- list(a1="welcome", a2b=list(b1="my friend", b2="bob", b3=list(d1=1, d2=2)))
A$a2b$
Also, I think that Tinn-R interprets word separator characters like if the code was normal text, with the consequence that R object names containing "_", "." are split and cannot be found in R environment, nor offer data completion.
My suggestion is that when one completion shorcut trigger is used (for function, or data/list), Tinn-R engine reads code left of the text cursor, until a real separator is found:
- for functions, that would be in two steps: 1) finding the open parenthesis; 2) reading the full name of the function, which may contain special symbols such as "_", ".", or be containing within an object, e.g. BigList$functionsDB$function3(par1=, par2=, ...)
- for lists, data.frames or any object with subitems, possibly with multiple nested levels of hierarchy: 1) finding the closest "sub" symbol ("$", or "@", or other?), then keep in memory the text that was right of it (if pattern match is active); 2) reading the full name and "path" of the object in case of nested structure, e.g. BigList$objectsDB$object14$subit_____
The general idea here is to consider the possibly nested structure of objects, thereby facilitating ~object-oriented programming in R for Tinn-R users, which becomes highly recommended when developing bigger scripts with lots of variables with various purposes such as graphical appearance, stat. distribution parameters, distinct groups of subitems for inputs vs outputs, etc.
Hope you'll be interested by these suggestions, I thank you for your time and nice work improving my favorite R IDE: Tinn-R!
Ciao.
Marc (alias marQIsoft)