[Rd] autocompletion problem
Herve Pages
hpages at fhcrc.org
Thu Apr 10 03:03:34 CEST 2008
Hi Deepayan,
Deepayan Sarkar wrote:
> On 4/9/08, Herve Pages <hpages at fhcrc.org> wrote:
>> Hi,
>>
>> Let's create the xxx object just to avoid confusion even if it's not necessary
>> for reproducing the problem below:
>>
>> xxx <- 8:3
>>
>> If I start typing this:
>>
>> max(xxx[
>>
>> and now try to autocomplete with <TAB>, then I get the following error (and a warning):
>>
>> > max(xxx[Error in grep(sprintf("^%s", makeRegexpSafe(text)), allArgs, value = TRUE) :
>> invalid regular expression '^xxx['
>> In addition: Warning message:
>> In grep(sprintf("^%s", makeRegexpSafe(text)), allArgs, value = TRUE) :
>> regcomp error: 'Invalid regular expression'
>
> Thanks for the report, makeRegexpSafe was not escaping "[". Does the
> following workaround fix the problem (without introducing additional
> ones)?
>
> assignInNamespace("makeRegexpSafe", ns = "utils", value = function(s)
> {
> s <- gsub(".", "\\.", s, fixed = TRUE)
> s <- gsub("?", "\\?", s, fixed = TRUE)
> s <- gsub("[", "\\[", s, fixed = TRUE)
> s <- gsub("]", "\\]", s, fixed = TRUE) # necessary?
> s
> })
Yes this fixes the problem. Thanks!
BTW are there any plans to deal with backquoted symbols/names?
There are currently 2 problems with this:
1. Completion will work and expand symbols or names that contain special
characters but without backquoting them:
xxx <- as.list(11:13)
names(xxx) <- letters[1:3]
names(xxx)[2] <- "2b"
> xxx$<TAB><TAB> # <TAB> stands for a hit on the Tab key
xxx$2b xxx$a xxx$c
> xxx$2b # I hit 2, then <TAB> gives me the b
Now if I hit <Enter>, of course I get:
Error: unexpected numeric constant in "xxx$2"
2. Completion of names after $ will not work if I've already backquoted
the partial name:
> xxx$`2<TAB><TAB><TAB>... # nothing happens
Thanks!
H.
>
> (with 2.6.x, replace "utils" with "rcompgen")
>
> -Deepayan
>
More information about the R-devel
mailing list