[ESS] History Expansion

Martin Maechler maechler at stat.math.ethz.ch
Tue Jun 22 09:46:50 CEST 2010

>>>>> "VJ" == Vinu Jacob <vinjacob at gmail.com>
>>>>>     on Tue, 22 Jun 2010 09:13:30 +0300 writes:

    VJ> Hello,
    VJ> I can't seem to get history expansion working with '!'
    VJ> or '^', as mentioned in the manual. 

which manual?   I don't think this ever worked (in R at least).

    VJ> Even '!!' does not give me the previous command, it waits for further commands with a '+'. This is on osx 10.6 with emacs 23.2.1 (Vincent Goulet's package)
    VJ> What could be wrong?

It's the Emacs-lisp function
which you want to call.
It's also on the "In/Out" Emacs menu, there labelled
"Previous Matching Current Input".

I (and many others I think, see below on *how*) have bound this
command to  "[up]" i.e. the up-arrow key, in addition to its traditional
binding  C-c M-r.   When I work inside *R* (not so often, I
prefer *.R and the "Eval-.." aka "send .. to R" commands) 
I use the up-key all the time for this feature

	C-h w   comint-previous-matching-input-from-input 

(when you are inside the *R* / *S+* buffer)
to show you to which keys it is bound.

Ok, here's the code to activate the up / down keys in that way

      (setq comint-scroll-to-bottom-on-output 'others) ; not current
      ;;=default: (setq comint-scroll-to-bottom-on-input nil)
      (setq comint-scroll-show-maximum-output t) ;;; this is the key
      (define-key comint-mode-map [up]
      (define-key comint-mode-map [down]

      (define-key comint-mode-map "\C-a" 'comint-bol)

The reason why we cannot do this in ESS already, is that it
influences all "Comint" based modes, e.g. also *shell* (M-x shell),
not just the ESS based ones.

Martin Maechler, ETH Zurich

More information about the ESS-help mailing list