Data completion now with CTRL+Space less handy than it was before...

15 views
Skip to first unread message

marQIsoft

unread,
Aug 7, 2016, 12:50:54 PM8/7/16
to Tinn-R Editor
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)

Jose Claudio Faria

unread,
Aug 8, 2016, 3:09:11 PM8/8/16
to marQIsoft, Tinn-R Editor
Hello Marc,

You are right in their observations and suggestions!
We will try to improve these aspects in the next version.

All the best,
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
Jose Claudio Faria
Estatistica
UESC/DCET/Brasil
joseclaudio.faria at gmail.com
Telefones:
55(73)3680.5545 - UESC
55(73)99966.9100 - VIVO
55(73)99100.7351 - TIM
55(73)98817.6159 - OI
55(73)98129.9942 - CLARO
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\

marQIsoft

unread,
Aug 11, 2016, 5:00:17 PM8/11/16
to Tinn-R Editor, marc.lau...@gmail.com
The code improvements included in Tinn-R since pre-release version 4.02.11 solved this marvellously!
There are still subtle cases to solve (that I'll describe someday), but now it works great in 99% cases.
Bravo! (and thanks again)

Marc


p.s. I've written this post simply to publicly confirm that the issues have been resolved.

Jose Claudio Faria

unread,
Aug 12, 2016, 8:37:09 AM8/12/16
to marQIsoft, Tinn-R Editor
Good news!

All the best,
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
Jose Claudio Faria
Estatistica
UESC/DCET/Brasil
joseclaudio.faria at gmail.com
Telefones:
55(73)3680.5545 - UESC
55(73)99966.9100 - VIVO
55(73)99100.7351 - TIM
55(73)98817.6159 - OI
55(73)98129.9942 - CLARO
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\


> --
> You received this message because you are subscribed to the Google Groups
> "Tinn-R Editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to tinn-r+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

marQIsoft

unread,
Aug 17, 2016, 6:54:11 PM8/17/16
to Tinn-R Editor, marc.lau...@gmail.com
Hi,

Today, I've noticed that data completion does not work with object names containing "_" or ".". Here are a few examples:

a.b = list(a=1:3, b=4:6)
a
.b$ #!wrongly says "object 'b' found"

a_b
= list(a=1:3, b=4:6)
a_b$
#!wrongly says "object 'b' found"

ok
<- list(not.ok=1, not_ok_either=2)
ok$not
.ok$ #!names displayed are from the wrong level (same as if ok$...)
ok$not_ok_either$
#!names displayed are from the wrong level (same as if ok$...)

Could you check this out, e.g. improve the reg. expression patterns?
Thanks.

Marc

Jose Claudio Faria

unread,
Aug 19, 2016, 6:25:59 AM8/19/16
to marQIsoft, Tinn-R Editor
Dear Marc,

Done, many thanks for pointing it out!
(You will see in the next pre-release version.)

https://regex101.com/r/mJ0xG4/4

The prior was

https://regex101.com/r/mJ0xG4/3

See Version above the RegEx.

Best,
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
Jose Claudio Faria
Estatistica
UESC/DCET/Brasil
joseclaudio.faria at gmail.com
Telefones:
55(73)3680.5545 - UESC
55(73)99966.9100 - VIVO
55(73)99100.7351 - TIM
55(73)98817.6159 - OI
55(73)98129.9942 - CLARO
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\


Jose Claudio Faria

unread,
Aug 19, 2016, 6:35:13 AM8/19/16
to marQIsoft, Tinn-R Editor
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
Jose Claudio Faria
Estatistica
UESC/DCET/Brasil
joseclaudio.faria at gmail.com
Telefones:
55(73)3680.5545 - UESC
55(73)99966.9100 - VIVO
55(73)99100.7351 - TIM
55(73)98817.6159 - OI
55(73)98129.9942 - CLARO
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\


data_completion.png

Marc Laurencelle

unread,
Aug 19, 2016, 12:01:26 PM8/19/16
to Jose Claudio Faria, Tinn-R Editor
Excellent! And the website you shared for viewing & testing reg. expressions is very nice too!
I've noticed, this morning, that .Machine$ did not work yet (with current version of Tinn-R). But I could test it with your new reg. expr. and it showed me that it will work in next release.

Thanks, and a nice weekend to you.

Marc

Marc Laurencelle

unread,
Aug 28, 2016, 2:23:01 PM8/28/16
to Jose Claudio Faria, Tinn-R Editor
Hi Jose,

I'm currently doing some programming in R. I've noticed that these lines are not correctly interpreted by current reg. expressions: with the consequence that Data completion does not display the good information.

The test code:
  text(somefunction(x=c(0.1, 0.9), y=c(0.9, 0.1), from="npc"), labels=c("overestimated", "underestimated"),  
  text(xydata, labels=c("overestimated", "underestimated"),

The issue:
When I put the cursor at the end of the first line (highlighted in orange), data completion (CTRL+Space) gives only a weird "function" text in the tip window, instead of detailing the possible arguments for the "text(...)" R function. Same thing happens if I put my cursor anywhere after the closing parenthesis for "somefunction", e.g. at the comma (highlighted in red).

A possible explanation:
To figure out why this happens, I've copied the line of code, and replaced the complex contents of first argument for text (which = somefunction(...)) by an object (here, xydata). And in this case, there is no problem: Data completion works as expected.

My diagnostic:
Current method for code interpretation (by regular expressions, probably?) is not fully compatible with "nested" function calls.

Could you check it out?

Thanks a lot.

Marc


Jose Claudio Faria

unread,
Sep 18, 2016, 7:52:22 PM9/18/16
to Marc Laurencelle, Tinn-R Editor
Hello Marc,

It was added to the TODO list of the project.
Many thanks for pointing it out.

Best,
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
Jose Claudio Faria
Estatistica
UESC/DCET/Brasil
joseclaudio.faria at gmail.com
Telefones:
55(73)3680.5545 - UESC
55(73)99966.9100 - VIVO
55(73)99100.7351 - TIM
55(73)98817.6159 - OI
55(73)98129.9942 - CLARO
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\


Reply all
Reply to author
Forward
0 new messages