From henrik.bengtsson at gmail.com  Fri Sep  2 23:15:58 2016
From: henrik.bengtsson at gmail.com (Henrik Bengtsson)
Date: Fri, 2 Sep 2016 14:15:58 -0700
Subject: [Rd] WISH: Export utils:::findMatches()
Message-ID: <CAFDcVCSm9prdrRpbs2Z9tg2Sea7dZrCo+seGNpr4QK1UYcCVSQ@mail.gmail.com>

WISH:

I'd like make a plea for utils:::findMatches() to be exported such
that anyone can do:

.DollarNames.MyClass <- function(x, pattern="") {
   utils:::findMatches(pattern, names(x))
}

The utils:::findMatches() is agile to the "fuzzy" options, cf.
.DollarNames.  It also doesn't erase what's been typed if there is not
match (see below).


ALTERNATIVE:
I'm aware of that utils:::.DollarNames.default almost do the same
thing, but, unfortunately, that does not work for all data type, e.g.
environment-based objects.  An alternative to utils:::findMatches() is
to use:

.DollarNames.MyClass <- function(x, pattern="") {
   grep(pattern, names(x), value=TRUE)
}

but that has the additional downside to return an empty string "" if
there's no match, which in turn erases whatever the user typed before
hitting TAB.


Thanks

Henrik



[Rd] WISH: Export utils:::findMatches()
Henrik Bengtsson