From deepayan.sarkar at gmail.com  Fri Aug 21 20:42:24 2009
From: deepayan.sarkar at gmail.com (Deepayan Sarkar)
Date: Fri, 21 Aug 2009 11:42:24 -0700
Subject: [Rd] more special completions
In-Reply-To: <op.uy0xe6epdacko8@tir-070312.staff.few.eur.nl>
References: <4A8E66FF.6000201@dbmail.com>
	<op.uy0xe6epdacko8@tir-070312.staff.few.eur.nl>
Message-ID: <eb555e660908211142p4c7954b4p4993bfc2fc052b1f@mail.gmail.com>

On 8/21/09, Vitalie S. <vitosmail at rambler.ru> wrote:
> On Fri, 21 Aug 2009 11:21:03 +0200, Romain Francois
> <romain.francois at dbmail.com> wrote:
>
>
> > Hi,
> >
> > Would it be possible to add the capability for functions to register how
> they would like to complete themselves.
> >
> > Currently, there is the .addFunctionInfo, but it allows only functions to
> register a static list of potential completions, I was thinking of a way to
> register not a fixed list of possible completions, but a __function__ that
> would calculate completions dynamically.
> >
> > This could be useful for the "new" function in R, if associated with
> something that can retrieve the current list of S4 classes (not sure this
> exists).
> >
> > Another example of where this could be used would be the .jnew function
> from rJava, where the first argument is a java class, associated with
> something that can complete java class names.
> >
>
>  Not sure, but another example may be a class dependent completion for
> generic functions depending on first argument. Like print(df,... ) where df
> a data.frame to complete, digits = NULL, quote = FALSE, right = TRUE,
> row.names = TRUE instead of only (x,...).

That sort of already happens (have you tried?), but instead of
print.data.frame, it gives you arguments of all print methods (only
for S3 generics though). Finding the right signature needs evaluation
of the right (usually first, but not necessarily) argument, which may
actually involve another function call. Inheritance makes things more
complicated. I'm not sure it's worth the overhead.

-Deepayan



[Rd] more special completions
Deepayan Sarkar