* Rafael Laboissiere <rafael.laboissi...@inserm.fr> [2010-08-12 20:24]:

> * Prof Brian Ripley <rip...@stats.ox.ac.uk> [2010-08-12 18:25]:
> 
> > If you provide a patch with these extremely important issues
> > resolved, we will consider its merits.  But not otherwise.
> 
> Please, tell me whether what I wrote above is okay and I will prepare a
> new patch containing the copyright clarification.

I did not hear from you but I went ahead and prepared a patch according
to your recommendations, attached below.  I hope that the copyright and
licensing issues are correctly sorted out now.

As I explained in my previous post, none of the lines of code that I
added are mine, so it does not make sense for me to claim copyright on
sys-std.c.  I did add my name and my personal email address though, for
credit purposes, but feel free to do whatever you think is appropriate.

Best regards,

Rafael Laboissiere
Index: src/unix/sys-std.c
===================================================================
--- src/unix/sys-std.c	(revision 52720)
+++ src/unix/sys-std.c	(working copy)
@@ -591,6 +591,88 @@
     onintr();
 }
 
+/* ============================================================
+   Add a function that accepts the current line for execution and
+   fetch the next line relative to the current line from the history for
+   editing.
+
+   The code below is taken as is from the bashline.c file of the 
+   Bash sources, version 3.0, available from
+   ftp://ftp.gnu.org/gnu/bash/bash-3.0.tar.gz
+
+   The header to this file contains the following copyright notice and
+   licencing conditions:
+
+   ============================================================
+   Copyright (C) 1987-2004 Free Software Foundation, Inc.
+
+   This file is part of GNU Bash, the Bourne Again SHell.
+
+   Bash is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   Bash is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Bash; see the file COPYING.  If not, write to the Free
+   Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+   ============================================================
+
+   This change was contributed originally by 
+   Rafael Laboissiere <raf...@laboissiere.net>
+
+*/
+
+#ifdef HAVE_READLINE_HISTORY_H
+
+/* === Start of code taken from bashline.c === */
+
+static rl_hook_func_t *old_rl_startup_hook = (rl_hook_func_t *)NULL;
+
+static int saved_history_line_to_use = -1;
+
+static int
+set_saved_history ()
+{
+  if (saved_history_line_to_use >= 0)
+    rl_get_previous_history (history_length - saved_history_line_to_use, 0);
+  saved_history_line_to_use = -1;
+  rl_startup_hook = old_rl_startup_hook;
+  return (0);
+}
+
+static int
+operate_and_get_next(int count, int c)
+{
+  int where;
+
+  /* Accept the current line. */
+  rl_newline (1, c);
+
+  /* Find the current line, and find the next line to use. */
+  where = where_history ();
+
+  if ((history_is_stifled () && (history_length >= history_max_entries)) ||
+      (where >= history_length - 1))
+    saved_history_line_to_use = where;
+  else
+    saved_history_line_to_use = where + 1;
+
+  old_rl_startup_hook = rl_startup_hook;
+  rl_startup_hook = set_saved_history;
+
+  return 0;
+}
+
+/* === End of code taken from bashline.c === */
+
+#endif
+
 #ifdef HAVE_RL_COMPLETION_MATCHES
 /* ============================================================
    function-completion interface formerly in package rcompletion by
@@ -887,6 +969,10 @@
 #ifdef HAVE_RL_COMPLETION_MATCHES
 	    initialize_rlcompletion();
 #endif
+#ifdef HAVE_READLINE_HISTORY_H
+            rl_add_defun ("operate-and-get-next", operate_and_get_next,
+                          CTRL ('O'));
+#endif
 	}
 	else
 #endif /* HAVE_LIBREADLINE */
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to