[R] R command history -- can it be like Matlab's?

Gad Abraham gabraham at csse.unimelb.edu.au
Sun Aug 3 11:54:50 CEST 2008


Peter Dalgaard wrote:
> Gad Abraham wrote:
>> Prof Brian Ripley wrote:
>>> A patch to do this was posted on 2007-09-29 by Glenn Davis.  Some 
>>> people not addicted to Matlab find the behaviour very inconvenient 
>>> and prefer the getline/readline behaviour (triggered by ^R/^S) of 
>>> Rterm and R on Unixen.
>>
>> Now that you've mentioned readline, it doesn't behave exactly the same 
>> in Bash and R: if you press ctrl-r and then ctrl-c in Bash, it breaks 
>> the search and you go back to the prompt as normal. In R on Linux (all 
>> versions I've tried, 2.2 to 2.7.1), doing that returns you to the 
>> prompt but you can't type anything, and the input buffer retains the 
>> text from the search, so pressing enter makes the historical command 
>> run again.
>>
>> Try this:
>> > ls()
>> character(0)
>> [ctrl-r]
>> (reverse-i-search)`l': ls()
>> [ctrl-c, then enter]
>> > ls()
>> character(0)
>>
>>
> Not quite true that you can't type anything. What happens (for me) is 
> that you are still in reverse-i-search, so you can get this effect from 
> "^R l ^C d".
> 
>  >
> (reverse-i-search)`l': ls()
> (reverse-i-search)`l': ls()
>  >
> (reverse-i-search)`l': ls()
> (reverse-i-search)`ld': levels(ftpain3) <- 
> list(none="none",intermediate=c("mild","medium"),severe="severe")
> 
> It snaps out of it if you press ^C twice.
> 

If try typing after a ctrl-C in reverse search mode , nothing displays, 
and the console beep sounds. It doesn't matter how many times I press 
ctrl-C, the same happens. The only way out of it is to press either 
enter (which shows the previously highlighted command ls and then runs 
it) or to use the up key, and then ctrl-C.

I'm using Ubuntu Hardy.

 > sessionInfo()
R version 2.7.1 (2008-06-23)
x86_64-pc-linux-gnu

locale:
LC_CTYPE=en_AU.UTF-8;LC_NUMERIC=C;LC_TIME=en_AU.UTF-8;LC_COLLATE=en_AU.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_AU.UTF-8;LC_PAPER=en_AU.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_AU.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

-- 
Gad Abraham
Dept. CSSE and NICTA
The University of Melbourne
Parkville 3010, Victoria, Australia
email: gabraham at csse.unimelb.edu.au
web: http://www.csse.unimelb.edu.au/~gabraham



More information about the R-help mailing list