From deepayan.sarkar at gmail.com  Thu Apr 10 00:29:17 2008
From: deepayan.sarkar at gmail.com (Deepayan Sarkar)
Date: Wed, 9 Apr 2008 15:29:17 -0700
Subject: [Rd] autocompletion problem
In-Reply-To: <47FD3697.8070606@fhcrc.org>
References: <47FD3697.8070606@fhcrc.org>
Message-ID: <eb555e660804091529w427f248cuf0a0fc97bb0aaac2@mail.gmail.com>

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



[Rd] autocompletion problem
Deepayan Sarkar