Hi Jose,
Considering the recent enhancements of completion/tip features regarding pattern matching using powerful and more robust regular expressions, could you apply the same "power" to the List Structure (F2) and similar tools? I refer, in particular, to the recognition of object names even when they have punctuation within, or hierarchy. Here are some examples which currently require a manual selection of the full name of the object prior to pressing F2:
r.object1 <- 1.234 #!Either 'r' or 'object1', but full name is not read, except if manu. selected
r_object2 <- 2.345 #Oh, this one already works; cool.
rlist3 <- list(a=1, b=2, c=3, d=4, e=list(aa=1, bb=2)) #(here, only creating the list object)
rlist3$a #!When the cursor is placed after the '$', F2 searches an object named 'a'. Instead, it should search for the list element 'rlist3$a'...
rlist3$e #!same problem, but should show the structure of element 'e' which is also a list
rlist3$e$bb #!same problem but one level deeper in the hierarchy.
My suggestion:
1. Use your updated regular expressions to treat punctuation characters correctly when reading object names such as 'r_object', 'r.object' or other special names with non-alphanumeric chars. This will do, for reading treating object names in absence of hierarchy...
2. To deal with hierarchical objects (in particular: lists!), use a regular expression which also take into account the position within a hierarchical list object, when '$' symbols are detected LEFT of the text-typing cursor. The idea is to read the R code starting with the "symbol" name right at the cursor, but continue reading leftwards until a real separator is found. Here are some examples:
rlist3$e$b[Cursor]b should show:
num 2
rlist3$e[Cursor]$bb should show:
List of 2
$ aa: num 1
$ bb: num 2
rlis[Cursor]t3$e$bb shows what we expect, because it's the level one (no hierarchy yet):
List of 5
$ a: num 1
$ b: num 2
$ c: num 3
$ d: num 4
$ e:List of 2
..$ aa: num 1
..$ bb: num 2
If you want to generalize the fixing of this ~issue, you may be interested in working on improving the recognition of "hierarchy" related to slots as well... Although used less frequently, some users may thank you if you also improve this. And I think it might be very easy to do: you probably just have to duplicate your regular expression so that it deals with '@' the same way as they would do with '$'. If I remember well, regular expressions allow 'A or B' criteria, which may be appropriate here?...
Moreover, I would add that although the ~issues I've described here are related to the F2 tool, some other tools from Tinn-R may share the same limitations, e.g. the example tool (CTRL+F1). Therefore, I invite you to generalize the improvements to these other tools, when it's relevant.
Lastly, as a complement to what I described above, I'd like to suggest a minor but cool improvement you could add to the Help tools (help F1, example CTRL+F1, open example CTRL+F2). Currently, when the object name under the cursor (or manually selected text) is a reserved word or a special symbol such as an operator, the help tools don't work correctly. The solution is very simple. You would just have to add quotes around the name to avoid misinterpretation by R. Here are some problematic symbols: for, while, +, %/%, [, ..., and many others. I'm not 100% sure, but I think the solution I propose (...to add quotes around the selected or at-cursor text...) can solve this minor issue completely.
I hope these suggestions will interest you.
And I wish you a good week.
Marc (alias marQIsoft)