From rafael.laboissiere at inserm.fr  Sun Aug  8 20:55:29 2010
From: rafael.laboissiere at inserm.fr (Rafael Laboissiere)
Date: Sun, 8 Aug 2010 20:55:29 +0200
Subject: [Rd] readline operate-and-get-next
In-Reply-To: <20100807110740.GB13899@pc049-u864.lyon.inserm.fr>
References: <20100807110740.GB13899@pc049-u864.lyon.inserm.fr>
Message-ID: <20100808185529.GC2603@pc049-u864.lyon.inserm.fr>

Okay, I could not refrain myself and implemented the change in
src/unix/sys-std.c.  The patch is attached below.  I tested it in the
2.11.1 source and it worked fine.  At any rate, the patch applies cleanly
to the SVN source.

Three notes about this patch:

1. The code is taken from the bash source (bashline.c) with minimal
   changes.
   
2. The changes are put inside #ifdef HAVE_READLINE_HISTORY_H, because
   it uses history related functions.
   
3. In the call to rl_add_defun, the operate-and-get-next function is
   bound to C-o.  This is not the behavior of Bash and Octave, which
   depends on the user to define the key binding in ~/.inputrc.  To
   mimic this behavior, the code should be rather:

   rl_add_defun ("operate-and-get-next", operate_and_get_next, -1);


Best regards,

Rafael Laboissiere

* Rafael Laboissiere <rafael.laboissiere at inserm.fr> [2010-08-07 13:07]:

> Both Bash and Octave have a nifty addition to the readline library called
> "operate-and-get-next", bound to "C-o".  This function accepts the
> current line for execution and fetch the next line relative to the
> current line from the history for editing (see
> http://www.faqs.org/docs/bashman/bashref_101.html).
> 
> This feature has a huge impact in my productivity using Bash and Octave
> interactively, since it avoids those numerous arrow key strokes in order
> to rerun a previous block of commands. 
> 
> I looked at the Bash sources and it does not seem too complicate to
> implement.  Octave has borrowed practically the same code from Bash.
> Before I start looking at the R code, I would like to know whether the R
> developers had already planned to include the operate-and-get-next
> feature into R.
> 
> Best regards,
> 
> Rafael Laboissiere
-------------- next part --------------
A non-text attachment was scrubbed...
Name: operate-and-get-next.patch
Type: text/x-diff
Size: 1800 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20100808/b0de6098/attachment.bin>


[Rd] readline operate-and-get-next
Rafael Laboissiere