[ESS] History Expansion

Vinu Jacob vinjacob at gmail.com
Tue Jun 22 10:05:52 CEST 2010

Hi Martin,

I will try and bind it to [up] as you recommend. Actually the "note" to bind it is also hinted to in the manual since the default binding as per section 4.5 of the manual is 'A-M-r'. The reason why I looked into '!' expansion is because section 4.6 at least  in my reading implied that this as a better alternative without having to rebind the command.

4.6 References to historical commands

Instead of searching through the command history using the command described in the previous section, you can alternatively refer to a historical command directly using a notation very similar to that used in csh.

Thanks & regards,


On Jun 22, 2010, at 10:46 AM, Martin Maechler wrote:

>>>>>> "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?
> nothing.
> It's the Emacs-lisp function
>     comint-previous-matching-input-from-input
> 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
> Type
> 	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
>  (eval-after-load
>   "comint"
>   '(progn
>      (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]
>        'comint-previous-matching-input-from-input)
>      (define-key comint-mode-map [down]
>        'comint-next-matching-input-from-input)
>      (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