command history wishlist

Robin Hankin rksh at soc.soton.ac.uk
Mon Jul 12 11:22:33 CEST 2004


Hello everyone

I've been playing with "!!" and especially "^old^new" recently, 
neither of which I use
in bash sessions but seem to be very handy in ESS.

In BASH, there is a wonderful key sequence "meta-dot" (M-.) which puts
the last argument used on the command line, as in:

bash>  ls -l file.txt
[snip]
bash> cp <"meta-dot"> backupfile.txt

expands to "cp file.txt backupfile.txt"

I use this all the time. In ESS, I would like to do the same thing, 
as I tend to use very
long variable names, but there seem to be two distinct 
functionalities not quite
covered by"!!-n":

(1) something that expands to "the variable most recently assigned" 
(call this 'keystroke X")
(2) something that expands to "the variable that was last  used as an 
argument (call this "keystroke Y")

Then

R>  c(1,2,5, 44, 6 ) -> z    #note spaces
R> plot "<keystroke X>"

gives "plot(z)"

*and*


R> plot(sort(z))
R> hist "<keystroke Y>"

gives "hist(z)"


I think this would be very useful, better even than M-. is in bash 
(which I use all the time).
One can get some of this functionality with "!!:n", but this doesn't 
work quite as desired
because "plot(x)" counts as one word (and anyway you'd have to count 
to find which one
you wanted).

Things like "!!*" don't quite work for me,
because "word" is defined as things which appear between two spaces, 
rather than as
syntactical units.  Thus "c(1,2, 3,4,5)" has  "3,4,5)" for  word 1, 
which I don't find terribly useful.

The other thing I noticed is that things like "!!^" aren't expanded 
in situ.  I'd like to do
R> x <- 1:5
R> plot( <keystroke "!!^"> )
to give "plot(x)" . . . but this doesn't expand as I want because the 
!! construction needs to be on
a line of its own (I think).

One solution would be to have a keystroke that expands to 'everything 
to the left of "<-"
or to the right of "->"  on the previous line'  and another keystroke 
that expands to 'the thing at the deepest level of brackets on the 
previous line'

Could I add these two to an ESS wishlist?

just my 2 cents.

Comments anyone?


-- 
Robin Hankin
Uncertainty Analyst
Southampton Oceanography Centre
SO14 3ZH
tel +44(0)23-8059-7743
initialDOTsurname at soc.soton.ac.uk (edit in obvious way; spam precaution)




More information about the ESS-help mailing list