From murdoch at stats.uwo.ca  Sat Apr 26 23:21:06 2008
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Sat, 26 Apr 2008 17:21:06 -0400
Subject: [Rd] RFC: What should ?foo do?
In-Reply-To: <alpine.LFD.1.10.0804251931290.23000@gannet.stats.ox.ac.uk>
References: <48110D8B.10300@stats.uwo.ca>
	<48115131.7000402@comcast.net>	<4811B9EC.3010701@stats.uwo.ca>
	<4811F8A8.1050108@comcast.net>	<f8e6ff050804250831g7198fe33s6e92a13ed7deb3ca@mail.gmail.com>	<481202A4.2030508@comcast.net>	<eb555e660804251054kaabb1c4r237007ff5703ca5f@mail.gmail.com>
	<alpine.LFD.1.10.0804251931290.23000@gannet.stats.ox.ac.uk>
Message-ID: <48139CC2.8090801@stats.uwo.ca>

On 25/04/2008 2:47 PM, Prof Brian Ripley wrote:
> On Fri, 25 Apr 2008, Deepayan Sarkar wrote:
> 
>> For what it's worth, I use ?foo mostly to look up usage of functions
>> that I know I want to use, and find it perfect for that (one benefit
>> over help() is that completion works for ?). The only thing I miss is
>> the ability to do the equivalent of help("foo", package = "bar");
>> ?bar::foo gives the help page for "::". Perhaps that would be
>> something to consider for addition.
> 
> That fits most naturally with the (somewhat technical) idea that bar::foo 
> becomes a symbol and not a function call.  I believe that several of think 
> that is in principle a better idea, but no one has as yet (AFAIK) explored 
> the ramifications.
> 
> However, 5 mins looking at the sources suggests that it is easy to do.


And you already did.  Thanks!

I'm going to make the following change soon (in R-devel).

??foo

will now be like help.search("foo").  This will work with your change, 
so ??utils::foo will limit the search to the utils package.  This is 
also quite easy.  A more difficult thing I'd like to do is to broaden 
the search to look outside the man pages, but that's a lot harder, and I 
haven't started on it.

I will also follow Hadley's suggestion and change the format of the 
help.search results, so you can just cut and paste after a question mark 
to look up the particular topic, e.g.  ??foo gives

utils::citEntry         Writing Package CITATION Files

Type '?PKG::FOO' to inspect entry 'PKG::FOO TITLE'.

I haven't touched the case of ?foo failing; I'll want to try it for a 
while to decide whether I like it best as is:

 > ?foo
No documentation for 'foo' in specified packages and libraries:
you could try '??foo'

or whether it should just automatically call help.search, or something 
in between.

Duncan Murdoch



[Rd] RFC: What should ?foo do?
Duncan Murdoch