[Rd] autocompletion problem

Deepayan Sarkar deepayan.sarkar at gmail.com
Thu Apr 10 00:29:17 CEST 2008


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
})

(with 2.6.x, replace "utils" with "rcompgen")

-Deepayan



More information about the R-devel mailing list