From ripley at stats.ox.ac.uk  Tue Oct 24 10:52:50 2006
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Tue, 24 Oct 2006 09:52:50 +0100 (BST)
Subject: [Rd] ANN/RFC: package providing TAB completion for
 readline-based R
In-Reply-To: <453DC669.9070605@statistik.uni-dortmund.de>
References: <eb555e660610231651q7a2c399ch3dff71bad6abf246@mail.gmail.com>
	<453DC669.9070605@statistik.uni-dortmund.de>
Message-ID: <Pine.LNX.4.64.0610240900100.32267@gannet.stats.ox.ac.uk>

On Tue, 24 Oct 2006, Uwe Ligges wrote:

>
>
> Deepayan Sarkar wrote:
>> Announcement:
>>
>> (For those every-once-in-a-while occasions when you run R from a
>> terminal instead of Emacs, and then wish something would happen when
>> you hit TAB...)
>>
>> Last week, I started looking at the GNU Readline documentation to see
>> if I could figure out how to use it for command completion within R.
>> It turned out to be easier than I had expected, and I now have a beta
>> version of the 'rcompletion' package available at
>>
>> http://www.stat.wisc.edu/~deepayan/R/rcompletion_0.0-6.tar.gz
>>
>>> From the help page:
>>
>> Description:
>>
>>      This package provides pseudo-intelligent TAB completion for a
>>      readline enabled instance of R when it is run from a terminal (or
>>      more specifically, an interface which uses readline to accept user
>>      input). It has no effect on the various GUI interfaces to R,
>>      including ESS and the standard Windows interface.
>>
>> For more details, install and load the package, then type
>>
>> package?rcompletion
>>
>> at the R prompt. Testing and feedback would be appreciated. Feature
>> requests and patches are also welcome, of course.
>>
>>
>> Questions:
>>
>> There are a couple of things about which I would like some advice:
>>
>> (1) The package currently contains a very rudimentary configure script
>> which stops installation when readline is not found. I'm not sure if
>> this is portable enough. .../src/unix/sys-std.c has more sophisticated
>> conditional directives, but I don't know enough about this sort of
>> thing to interpret those. Any thoughts or suggestions on this would be
>> appreciated.

I don't think that is safe.  You can have R installed with readline 
support even if there are neither readline headers nor library on the 
current machine (use a static library), and R can be run without readline 
(via --no-readline) even if it is installed.

However, your configure script fails on my machine (x86_64 FC5).  It seems 
that you need both to get LDFLAGS and LD_LIBRARY_PATH from R and use them, 
and also use a version of autoconf that knows about lib64 (since the 
readline DSO is in /usr/lib64).  Since I don't get any further I am not 
sure what really happens, but it seems you don't link your DLL against 
-lreadline, and I think you need to to allow for static libreadline.a (the 
relevant code seems to be a separate .o and so is likely not linked into R 
in that case).

I guess that you want to know that R was installed with readline support 
at install time, and is running with the readline console?  It is not 
immediately obvious to me that either is currently known to a package 
writer/user.

>> (2) What's the recommended procedure to distribute this, given that
>> (a) it's not relevant on Windows (i.e. won't do anything even if it
>> could be installed) and (b) may or may not be relevant on Macs, some
>> of which apparently have a fake readline that doesn't support
>> completion?
>
>
> Distribution can happen regularly as a CRAN package. I will put it on my
> exclude list in order not to try building Windows binaries in that case.

I think there should also be a configure.win which explains that the 
package is not usable on Windows, in case someone tries to install from 
the sources.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




[Rd] ANN/RFC: package providing TAB completion for readline-based R
Prof Brian Ripley