code:
2008-05-07  Ludovic Courtès  <ludo@gnu.org>

	* ice-9/Makefile.am (guile_pdd): Don't use `patsubst': it's GNU
	Make and broke BSD Make as found on FreeBSD 6.2.

2008-04-16  Ludovic Courtès  <ludo@gnu.org>

	* configure.in (AC_INIT): Don't use "echo -n", which is not
	available on MacOS X; use `patsubst' instead to remove the
	newline.  Reported by Steven Wu <wus@qwest.net>.

2008-02-16  Ludovic Courtès  <ludo@gnu.org>

	* LIBGUILEREADLINE-VERSION
	(LIBGUILEREADLINE_INTERFACE_REVISION): Increment for release.

2008-01-29  Neil Jerram  <neil@ossau.uklinux.net>

	* readline.c (scm_init_readline): Only do init_bouncing_parens ()
	if HAVE_RL_GET_KEYMAP.
	(init_bouncing_parens, find_matching_paren, match_paren): Compile
	out if ! HAVE_RL_GET_KEYMAP.

	* configure.in: Add check for rl_get_keymap.

2007-07-15  Ludovic Courtès  <ludo@gnu.org>

	* LIBGUILEREADLINE-VERSION
	(LIBGUILEREADLINE_INTERFACE_REVISION): Incremented for release.

2007-06-26  Ludovic Courtès  <ludo@gnu.org>

	* readline.c (scm_add_history): Free S after invocation of
	`add_history ()'.

2006-10-06  Rob Browning  <rlb@defaultvalue.org>

	* LIBGUILEREADLINE-VERSION (LIBGUILEREADLINE_INTERFACE_REVISION):
	Increment for release.

2006-10-05  Kevin Ryde  <user42@zip.com.au>

	* ice-9/readline.scm (filename-completion-function): Export this.

2006-05-15  Kevin Ryde  <user42@zip.com.au>

	* Makefile.am (INCLUDES): Add "-I." to pick up guile-readline-config.h
	in snarfer.

2006-04-18  Rob Browning  <rlb@defaultvalue.org>

	* .cvsignore: Add guile-readline-config.h and
	guile-readline-config.h.in.

	* readline.c: Don't include Guile private header _scm.h.
	Include new guile-readline-config.h private header.

	* configure.in: Add AC_CONFIG_AUX_DIR([.]) as suggested in the
	autotools documentation.  Add
	AM_CONFIG_HEADER([guile-readline-config.h]) so that guile-readline
	will have its own configure-based config.h equivalent.
	(HAVE_RL_PRE_INPUT_HOOK): Add documentation template.
	(GUILE_SIGWINCH_SA_RESTART_CLEARED): Add documentation template.

2006-03-12  Neil Jerram  <neil@ossau.uklinux.net>

	* ice-9/readline.scm (make-completion-function): New.

2006-02-06  Marius Vollmer  <mvo@zagadka.de>

	* LIBGUILEREADLINE-VERSION: Bumped versions for 1.8.

2005-03-02  Marius Vollmer  <marius.vollmer@uni-dortmund.de>

	* readline.c: Use scm_current_input_port instead of scm_cur_inp.
	Use scm_std_select instead of scm_internal_select.

2004-08-26  Marius Vollmer  <marius.vollmer@uni-dortmund.de>

	* LIBGUILEREADLINE-VERSION: Bumped versions for the 1.7.1 release.
	Added LIBGUILEREADLINE_MAJOR variable for inclusion in the name of
	the shared library.
	* configure.in: AC_SUBST it.
	* Makefile.am: Substitute it into name of library.
	* ice-9/readline.scm: Use new name with load-extension.

2004-08-19  Marius Vollmer  <marius.vollmer@uni-dortmund.de>

	* readline.c: Avoid the use of discouraged or
	deprecated things.

2004-07-06  Marius Vollmer  <marius.vollmer@uni-dortmund.de>

	* readline.c: Replaced all uses of deprecated SCM_FALSEP,
	SCM_NFALSEP, SCM_BOOL, SCM_NEGATE_BOOL, and SCM_BOOLP with
	scm_is_false, scm_is_true, scm_from_bool, and scm_is_bool,
	respectively.

2004-06-16  Rob Browning  <rlb@defaultvalue.org>

	* configure.in: move package and version args to AC_INIT as is now
	recommended.  This also requires m4_esyscmd to read GUILE-VERSION
	given the way AC_INIT handles its args.  Also move "foreign"
	indication here.

	* Makefile.am: move support for readline.scm to ice-9/ subdir.

	* readline.scm: moved to ./ice-9/

	* .cvsignore: add ice-9 dir.

	* ice-9/Makefile.am: new file.

	* ice-9/readline.scm: moved here from ../

	* ice-9/.cvsignore: new file.

2004-02-15  Mikael Djurfeldt  <mdj@chunk.mit.edu>

	* configure.in: Use AC_PROG_LIBTOOL instead of AM_PROG_LIBTOOL.

2004-02-08  Mikael Djurfeldt  <djurfeldt@nada.kth.se>

	* Makefile.am (TAGS_FILES): Use this variable instead of
	ETAGS_ARGS so that TAGS can be built using separate build
	directory.

2003-05-04  Marius Vollmer  <mvo@zagadka.de>

	* configure.in: When checking whether readline clears SA_RESTART,
	let readline read from "/dev/null".  Otherwise, it might be
	stopped when run in the background with job control, say.
	Thanks to Michael Talbot-Wilson!

2003-04-05  Mikael Djurfeldt  <djurfeldt@nada.kth.se>

	The intended side-effect of the following change is to make the
	prompt appear properly when debugging or running Guile in an Emacs
	buffer.  (The readline library has some prompt magic which we were
	expected to do ourselves when we were bold enough to provide our
	own redisplay function---but we don't need to do that.)

	* readline.c (redisplay): Removed. (It didn't do anything other
	than calling rl_redisplay.)
	(scm_init_readline): Don't inititalize rl_redisplay_function.

2003-03-19  Rob Browning  <rlb@defaultvalue.org>

	* readline.c: add HAVE_CONFIG_H test guarding #include config.h.

	* autogen.sh: add a --force when autoreconfing.  We may need to
	change this if it doesn't work out...

	* Makefile.am (ice-9/readline.scm): new target -- so readline will
	work from the source tree when guile-readline is added to
	GUILE_LOAD_PATH.
	(all-local): add ice-9/readline.scm.
	(clean-local): remove ice-9/readline at clean time.

2003-02-27  Rob Browning  <rlb@defaultvalue.org>

	* autogen.sh: use autoreconf.

2003-01-08  Neil Jerram  <neil@ossau.uklinux.net>

	* readline.c (scm_readline): Check that scm_cur_outp is an output
	port, not an input one.

2002-12-08  Rob Browning  <rlb@defaultvalue.org>

	* configure.in (GUILE_EFFECTIVE_VERSION): AC_SUBST.

	* Makefile.am (ice9dir): VERSION -> GUILE_EFFECTIVE_VERSION.

2002-10-27  Marius Vollmer  <mvo@zagadka.ping.de>

	* readline.c (reentry_barrier_mutex): Reimplemented with
	scm_make_mutex, etc.

2002-10-21  Mikael Djurfeldt  <mdj@linnaeus>

	* readline.scm (activate-readline): Look for use-emacs-interface
	option in the guile-user module instead of the-root-module.

2002-04-30  Marius Vollmer  <marius.vollmer@uni-dortmund.de>

	* autogen.sh: Invoke plain aclocal instead of guile-aclocal.sh.
	We don't need the Guile m4 macros and the previous invocation of
	guile-aclocal.sh created the aclocal.m4 file in the wrong
	directory (see change from 2002-04-26).

2002-04-26  Marius Vollmer  <mvo@zagadka.ping.de>

	* autogen.sh: Change to parent dir before invoking
	guile-aclocal.sh.

2002-04-16  Marius Vollmer  <mvo@zagadka.ping.de>

	* Makefile.am (dist-hook): Make sure $(distdir)/Makefile.in is
	writable before modifying it.

2002-04-10  Rob Browning  <rlb@defaultvalue.org>

	* configure.in: add definitions to AC_DEFINE calls for new
	autoconf.

	* .cvsignore: add autom4te.cache and *.c.clean.c.

2002-03-24  Marius Vollmer  <mvo@zagadka.ping.de>

	* Makefile.am (.c.x): Pass "-o $@" to guile-snarf.

2002-03-13  Thien-Thi Nguyen  <ttn@giblet.glug.org>

	* Makefile.am (snarfcppopts): New var.
	(.c.x): Use $(snarfcppopts). Rework guile-snarf usage.

2002-02-27  Stefan Jahn  <stefan@lkcc.org>

	* Makefile.am (EXTRA_DIST): Added the `LIBGUILEREADLINE-VERSION'
	file.

2002-02-25  Thien-Thi Nguyen  <ttn@giblet.glug.org>

	* configure.in (LIBGUILEREADLINE-VERSION):
	Look for this file in $srcdir.

2002-02-24  Rob Browning  <rlb@defaultvalue.org>

	* configure.in: source ./LIBGUILEREADLINE-VERSION for version info
	and then AC_SUBST the resulting variables:
	LIBGUILEREADLINE_INTERFACE_CURRENT,
	LIBGUILEREADLINE_INTERFACE_REVISION,
	LIBGUILEREADLINE_INTERFACE_AGE, and
	LIBGUILEREADLINE_INTERFACE.

	* Makefile.am (libguilereadline_la_LDFLAGS): use
	@LIBGUILEREADLINE_INTERFACE@ for version information.

	* LIBGUILEREADLINE-VERSION: new file containing shared lib
	versioning information.

2002-02-12  Thien-Thi Nguyen  <ttn@giblet.glug.org>

	* Makefile.am (AUTOMAKE_OPTIONS): Replace "gnu" with "foreign".
	This undoes the 2002-02-08 change.

2002-02-08  Thien-Thi Nguyen  <ttn@giblet.glug.org>

	* Makefile.am (AUTOMAKE_OPTIONS): Replace "foreign" with "gnu".

2002-01-29  Neil Jerram  <neil@ossau.uklinux.net>

	* readline.scm (with-readline-completion-function): Renamed from
	`call-with-readline-completion-function'.

2001-11-30  Neil Jerram  <neil@ossau.uklinux.net>

	* Makefile.am (EXTRA_DIST): Refer to $(ice9_DATA) rather than
	readline.scm explicitly.
	(ETAGS_ARGS): Added.

2001-11-04  Stefan Jahn  <stefan@lkcc.org>

	* configure.in (EXTRA_DEFS): Follow-up patch.  Using SCM_IMPORT
	instead of __SCM_IMPORT__.

	* readline.c (scm_readline_init_ports): Disable input/output
	stream redirection for Win32.  The readline package for Win32
	does not support this.  The guile-readline library works fine
	for command line editing.

	* readline.h (SCM_RL_API): Renamed __FOO__ macros into FOO.

2001-11-02  Marius Vollmer  <mvo@zagadka.ping.de>

	Support for native Win32.  Thanks to Stefan Jahn!

        * Makefile.am: Put `-export-dynamic -no-undefined' into LDFLAGS
        and add the library `libguile.la' to support linkers which do not
        allow unresolved symbols inside shared libraries.

        * configure.in: Define AC_LIBTOOL_WIN32_DLL to build clean dlls
        on Win32 platforms.
        Define extra compiler flags necessary to build clean dlls.

        * readline.c: Include `io.h' and exclude `sys/time.h' for MinGW.

        * readline.h: Defintion of SCM_RL_API.  Prefixed each exported
        symbol with SCM_RL_API.

2001-08-31  Dirk Herrmann  <D.Herrmann@tu-bs.de>

	* readline.c (scm_readline, scm_add_history,
	scm_filename_completion_function, completion_function):  Remove
	calls to SCM_STRING_COERCE_0TERMINATION_X.  Since the substring
	type is gone, all strings are 0-terminated anyway.

2001-08-31  Dirk Herrmann  <D.Herrmann@tu-bs.de>

	* readline.scm: `feature?' is deprecated.  Use `provided?'
	instead.

2001-08-25  Marius Vollmer  <mvo@zagadka.ping.de>

	* readline.scm: Use load-extension instead of explicit
	dynamic-link/dynamic-call.  Removed ".so" extension from library
	name.

2001-08-02  Neil Jerram  <neil@ossau.uklinux.net>

	* readline.scm (call-with-readline-completion-function): New.

2001-07-18  Martin Grabmueller  <mgrabmue@cs.tu-berlin.de>

	* Makefile.am, readline.scm: Updated copyright notice.

2001-07-09  Thien-Thi Nguyen  <ttn@revel.glug.org>

	* readline.c: Remove "face-lift" comment.

2001-06-30  Dirk Herrmann  <D.Herrmann@tu-bs.de>

	* readline.c (completion_function):  Use scm_list_n instead of
	SCM_LISTn.

2001-06-14  Marius Vollmer  <mvo@zagadka.ping.de>

	* readline.c, readline.h: Replace "scm_*_t" with "scm_t_*".

2001-06-14  Marius Vollmer  <mvo@zagadka.ping.de>

	Thanks to Matthias Köppe!

	* configure.in: Check for rl_filename_completion_function.
	* readline.c (s_scm_filename_completion_function): Use
	rl_filename_completion_function instead of
	filename_completion_function, if we have it.
	(scm_init_readline): Use rl_compentry_func_t instead if Function
	when _RL_FUNCTION_TYPEDEF is defined.

	* readline.h (scm_clear_history): New prototype.

2001-06-07  Dirk Herrmann  <D.Herrmann@tu-bs.de>

	* readline.c (current_input_getc):  Mark unused parameters with
	SCM_UNUSED.

2001-06-03  Marius Vollmer  <mvo@zagadka.ping.de>

	* configure.in: Added AC_PREREQ(2.50) and minimally changed for
	autoconf 2.50.  This is mostly so that the `transparent autoconf
	wrapper' on Debian picks the right version of autoconf.

2001-05-31  Michael Livshin  <mlivshin@bigfoot.com>

	* Makefile.am (libguilereadline_la_SOURCES): removed readline.x
	from here (not needed).
	(CLEANFILES): added *.x (and removed from DISTCLEANFILES).
	(MKDEP): copied from libguile/Makefile.am.  not that it matters
	now, but it will if we stop using BUILT_SOURCES for some reason.

2001-05-24  Martin Grabmueller  <mgrabmue@cs.tu-berlin.de>

	Make it compile with --disable-deprecated.

	* readline.h: scm_option->scm_option_t.

	* readline.c (stream_from_fport): scm_fport->scm_fport_t;
	scm_option->scm_option_t.

2001-05-23  Michael Livshin  <mlivshin@bigfoot.com>

	* readline.c (strdup): make `len' a size_t.

2001-05-10  Marius Vollmer  <mvo@zagadka.ping.de>

	* readline.c (completion_function): Use SCM_VARIABLE_REF to access
	scm_readline_completion_function_var.
	(scm_init_readline): Use scm_c_define instead of scm_sysintern to
	create scm_readline_completion_function_var.

2001-04-09  Marius Vollmer  <mvo@zagadka.ping.de>

	* readline.c (scm_clear_history): New function.
	* readline.scm (readline-port): Call clear-history on exit.
	Thanks to Utz-Uwe Haus.

2001-03-09  Keisuke Nishida  <kxn30@po.cwru.edu>

	* readline.c: Add #include <stdio.h>

2001-03-05  Neil Jerram  <neil@ossau.uklinux.net>

	* readline.scm (make-readline-port): Rewrite using
	make-line-buffered-input-port.
	(activate-readline): Call set-buffered-input-continuation?!.

2001-01-28  Marius Vollmer  <mvo@zagadka.ping.de>

	* readline.scm (make-readline-port): PROMPT becomes PROMPT2 as
	soon as GET-CHARACTER returns any character at all that was
	previously read.  This makes the continuation prompt appear
	properly for partial expressions.  Thanks to Neil Jerram!

2001-01-26  Dirk Herrmann  <D.Herrmann@tu-bs.de>

	This patch fixes a problem reported by Martin Grabmueller about
	the impossibility to access readline's run-time options.

	* readline.scm:  Added a comment about guile's behaviour if one of
	the ports used by readline are closed.

	(readline-options readline-enable readline-disable,
	readline-set!):  These are now defined here instead of in
	boot-9.scm.

2001-01-25  Dirk Herrmann  <D.Herrmann@tu-bs.de>

	* readline.scm (set-readline-input-port!,
	set-readline-output-port!):  Make sure that only valid port
	parameters are passed.  Thanks to Martin Grabmueller for sending
	a patch that formed the basis for this change.

2001-01-18  Neil Jerram  <neil@ossau.uklinux.net>

	* readline.scm (make-readline-port): Make readline port
	input-only.

2000-12-12  Dirk Herrmann  <D.Herrmann@tu-bs.de>

	* readline.scm (activate-readline):  Lookup 'use-emacs-interface
	in the-root-module.

2000-11-24  Dirk Herrmann  <D.Herrmann@tu-bs.de>

	* readline.c (current_input_getc):  Use more explicit predicate
	than SCM_NIMP.

	(scm_readline, scm_readline_init_ports, completion_function):
	Remove redundant SCM_N?IMP tests.

	(scm_readline):  Fixed default input/output port parameter
	handling.

2000-11-24  Dirk Herrmann  <D.Herrmann@tu-bs.de>

	* readline.c (scm_readline, scm_add_history, completion_function,
	scm_filename_completion_function):  Replace calls to
	SCM_COERCE_SUBSTR with SCM_STRING_COERCE_0TERMINATION_X.

	(internal_readline, scm_add_history, scm_read_history,
	scm_write_history, scm_filename_completion_function,
	completion_function):  Replace SCM_CHARS with SCM_STRING_CHARS.

2000-11-19  Gary Houston  <ghouston@arglist.com>

	* configure.in: test $ac_cv_lib_readline_readline instead of
	$ac_cv_lib_readline_main.  Thanks to Lars J. Aas.

2000-09-17  Marius Vollmer  <mvo@zagadka.ping.de>

	* configure.in: Check for curses, terminfo and termlib libraries
	in addition to ncurses and termcap.
	Check for `readline' in libreadline, not for `main'.
	Thanks to Albert Chin!

2000-07-17  Marius Vollmer  <mvo@zagadka.ping.de>

	* configure.in (rl_pre_input_hook): Don't check for this with
	AC_CHECK_FUNCS, it doesn't work on HP/UX.  Test for it with
	AC_TRY_LINK.

2000-06-19  Mikael Djurfeldt  <mdj@thalamus.nada.kth.se>

	* readline.c (sigwinch_enable_restart, scm_init_readline):
	Re-enable restart for SIGWINCH signal.

	* configure.in: Added test if readline clears SA_RESTART flag for
	SIGWINCH.  (Thanks to Dale P. Smith.)
	Check for siginterrupt and rl_pre_input_hook.

2000-06-14  Mikael Djurfeldt  <mdj@thalamus.nada.kth.se>

	* readline.c (scm_readline): Added parenthesis around && within
	||.
	Fixed up prototype for `reentry_barrier'.
	Conditionally #include <unistd.h>.  (Needed for `dup'.)

2000-06-13  Mikael Djurfeldt  <mdj@thalamus.nada.kth.se>

	* Makefile.am (dist-hook): Added kludge to fix automake generated
	dependencies in the distribution archive Makefile.

2000-06-12  Mikael Djurfeldt  <mdj@thalamus.nada.kth.se>

	* readline.scm (apropos-completion-function): Don't define and
	install if the 'regex feature is missing.

2000-06-06  Mikael Djurfeldt  <mdj@mdj.nada.kth.se>

	* readline.c: Always provide scm_init_readline, also if readline
	support is not included.  Otherwise, a strange dynamic loading
	error will occur.  (It would be better not to install
	libguilereadline at all.)

	* readline-activator.scm (activate-readline): Report an error if
	readline isn't provided by Guile.

	* readline.scm: Report an error if readline isn't provided by
	Guile;  Added :no-backtrace to module header.

	* configure.in: Put more ink before readline version warning.
	(Thanks to Ian Grant.)

2000-06-01  Michael Livshin  <mlivshin@bigfoot.com>

	* autogen.sh: call ../guile-aclocal.sh instead of aclocal

2000-05-01  Gary Houston  <ghouston@arglist.com>

	* readline.c: include libguile.h, not libguile/libguile.h.

2000-04-21  Mikael Djurfeldt  <mdj@thalamus.nada.kth.se>

	* *.*: Change includes so that they always use the "prefixes"
	libguile/, qt/, guile-readline/, or libltdl/.

	* Makefile.am (DEFS): Added.  automake adds -I options to DEFS,
	and we don't want that.
	(INCLUDES): Removed all -I options except for the root source
	directory and the root build directory.

2000-04-04  Dirk Herrmann  <D.Herrmann@tu-bs.de>

	* readline.c (scm_readline):  Must unpack SCM values to access
	their raw contents.

2000-03-19  Michael Livshin  <mlivshin@bigfoot.com>

	* *.[hc]: add Emacs magic at the end of file, to ensure GNU
 	indentation style.

2000-03-12  Mikael Djurfeldt  <mdj@thalamus.nada.kth.se>

	* readline.c (current_input_getc): Don't pass int values through
	SCM variables.
	(match_paren): Bugfix: First arg to select is not number of
	descriptors but the number of the highest descriptor + 1.

Thu Mar  9 08:00:26 2000  Greg J. Badros  <gjb@cs.washington.edu>

	* readline.c: scm_validate.h renamed to validate.h.

Wed Mar  8 10:43:10 2000  Greg J. Badros  <gjb@cs.washington.edu>

	* readline.c (match_paren): Use SELECT_TYPE, not fd_set, for type
 	of readset.

2000-01-25  Marius Vollmer  <mvo@zagadka.ping.de>

	* autogen.sh: Call libtoolize.  Pass --add-missing option to
	automake.

	* readline.scm: Only link glue code when the 'readline feature is
	not already present.  Thanks to Clark McGrew.

Tue Jan 11 17:51:40 2000  Greg J. Badros  <gjb@cs.washington.edu>

	* readline.c (scm_init_readline): Drop extra argument to
 	scm_mutex_init as that argument should not exist.  I do not know
	how this escaped detection for so long.

2000-01-09  Mikael Djurfeldt  <mdj@thalamus.nada.kth.se>

	* readline.c (match_paren): Changed return type to int (this is
	the definition in readline 4) and modified code layout according
	to GNU coding standards.

Wed Jan  5 11:18:01 2000  Greg J. Badros  <gjb@cs.washington.edu>

	* readline.c: Whitespace changes -- added space after
	SCM_VALIDATE_* macros to match GNU coding standards.

Wed Jan  5 11:02:40 2000  Greg J. Badros  <gjb@cs.washington.edu>

	* readline.c: Rename GUILE_PROC to SCM_DEFINE.

Mon Dec 13 13:57:57 1999  Greg J. Badros  <gjb@cs.washington.edu>

	* readline.c: Include libguile/scm_validate.h

Sun Dec 12 19:56:52 1999  Greg J. Badros  <gjb@cs.washington.edu>

	* readline.c: Updated to use GUILE_PROC, SCM_VALIDATE, and have
	(now empty) docstrings.

1999-11-18  Gary Houston  <ghouston@freewire.co.uk>

	* readline.c (scm_init_readline): set rl_readline_name to Guile,
	to allow conditionals in  .inputrc.

1999-10-05  Jim Blandy  <jimb@savonarola.red-bean.com>

	* Makefile.in, configure, aclocal.m4: Deleted from CVS repository.
	Run the autogen.sh script to create generated files like these.
	* autogen.sh: New script, invoked by the top-level autogen.sh.

1999-09-22  Jim Blandy  <jimb@savonarola.red-bean.com>

	* configure.in: Call AM_PROG_CC_STDC.
	* configure, aclocal.m4: Regenerated.

1999-09-16  Mikael Djurfeldt  <mdj@mdj-pc.nada.kth.se>

	* Makefile.am (.c.x): Use same rule as in libguile.

1999-09-12  Mikael Djurfeldt  <mdj@thalamus.nada.kth.se>

	* readline.h, readline.scm: Updated copyright notices.

1999-09-11  Mikael Djurfeldt  <mdj@thalamus.nada.kth.se>

	* readline.scm (activate-readline): Set (using-readline?).

1999-09-11  Jim Blandy  <jimb@savonarola.red-bean.com>

	* aclocal.m4: Regenerated with newer libtool macros.

	* Makefile.am (DISTCLEANFILES): Get rid of .x files.
	* Makefile.in: Regenerated.
	(Thanks to Keisuke Nishida.)

1999-09-11  Marius Vollmer  <mvo@zagadka.ping.de>

	* readline.scm: Moved from ../ice-9.
	Dynamically link libguilereadline.so.
	(readline): Just define in this module, do not overwrite builtin
	variable.  The builtin readline function is now named "%readline",
	so this works.  See below.
	(activate-readline): New function which contains the readline
	activation code formerly found in top-repl.

	* readline.c (scm_readline): Export it to Scheme as "%readline".

	* configure.in: Get version from ../GUILE-VERSION and use it for
	package version.

	* Makefile.am: Do not install and distribute
	readline-activator.scm.  Install and distribute readline.scm
	instead.

	* aclocal.m4, Makefile.in, configure, libtool: Regenerated, but
	probably with the wrong version of the tools.

1999-08-29  Mikael Djurfeldt  <mdj@thalamus.nada.kth.se>

	The following change makes it possible for applications to have
	their own version of scm_readline.
	* readline.c, readline.h (rl_cleanup_after_signal,
	rl_free_line_state): Made global.
	(scm_readline_init_ports): New function.
	(scm_readline): Use scm_readline_init_ports.
	(Thanks to Anders Holst.)

	* Makefile.am: Install guile-readline/readline.h.

1999-08-20  James Blandy  <jimb@mule.m17n.org>

	* Makefile.in, aclocal.m4, configure: Regenerated.

1999-08-17  Mikael Djurfeldt  <mdj@thalamus.nada.kth.se>

	* configure.in (HAVE_RL_GETC_FUNCTION): Modified test to actually
	use rl_getc_function.  Otherwise smart compilers, like gcc,
	optimize away the reference so that no error occurs in the link
	phase.

1999-08-04  Mikael Djurfeldt  <mdj@thalamus.nada.kth.se>

	* Makefile.am (INCLUDES): Added -I$(srcdir)/../libguile.
	(Thanks to Greg Badros.)

1999-07-24  Mikael Djurfeldt  <mdj@thalamus.nada.kth.se>

	* readline.c (handle_error): Put a cosmetic newline on
	rl_outstream on error before closing it.

	* configure.in: Changed AC_MSG_ERROR into AC_MSG_WARN in case
	readline doesn't exist on the system, so that configuration can
	proceed normally without readline.

	* readline.c: #include "libguile/_scm.h" (so that we get the
	configuration information) and fix other includes so that they'll
	work on a system where guile is not yet installed.

	* Makefile.am (BUILT_SOURCES): Added.

1999-07-23  Marius Vollmer  <mvo@zagadka.ping.de>

	* Checked everything into CVS.

1999-07-22  Marius Vollmer  <mvo@zagadka.ping.de>

	* readline.c (stream_from_fport): New function.
	(scm_readline): Use it to for the input and output ports.  Close
	the streams after readline returns.
	(handle_error): Close them also when an error occured.

1999-06-17  Marius Vollmer  <mvo@zagadka.ping.de>

	* readline.h, readline.c: Removed exception notice from copyright
	statement.

1999-05-16  Marius Vollmer  <mvo@zagadka.ping.de>

	* Started guile-readline package.  Files are copied from old
	guile-core package and slightly modified.

;; Local Variables:
;; coding: utf-8
;; End:


code:
# -*-shell-script-*-

# This file contains the shared library versioning information.  Right
# now, for this to work properly, you'll also need to add AC_SUBST
# calls to the right place in configure.in, add the right
# -version-info statement to your Makefile.am, and add a call to
# source this file from configure.in.  Later we may automate more of
# this.

LIBGUILEREADLINE_MAJOR=17
LIBGUILEREADLINE_INTERFACE_CURRENT=17
LIBGUILEREADLINE_INTERFACE_REVISION=3
LIBGUILEREADLINE_INTERFACE_AGE=0
LIBGUILEREADLINE_INTERFACE="${LIBGUILEREADLINE_INTERFACE_CURRENT}:${LIBGUILEREADLINE_INTERFACE_REVISION}:${LIBGUILEREADLINE_INTERFACE_AGE}"

path: guile-readline/LIBGUILEREADLINE-VERSION

license: unknown


code:
## Process this file with Automake to create Makefile.in
##
##  	Copyright (C) 1998, 1999, 2000, 2001, 2004, 2006, 2008 Free Software Foundation, Inc.
##
##   This file is part of GUILE.
##
##   GUILE 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.
##
##   GUILE 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 GUILE; see the file COPYING.  If not, write
##   to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
##   Floor, Boston, MA 02110-1301 USA

SUBDIRS = ice-9

## Prevent automake from adding extra -I options
DEFS = @DEFS@ @EXTRA_DEFS@
## Check for headers in $(srcdir)/.., so that #include
## <libguile/MUMBLE.h> will find MUMBLE.h in this dir when we're
## building.
INCLUDES = -I. -I.. -I$(srcdir)/..

GUILE_SNARF = ../libguile/guile-snarf

lib_LTLIBRARIES = libguilereadline-v-@LIBGUILEREADLINE_MAJOR@.la

libguilereadline_v_@LIBGUILEREADLINE_MAJOR@_la_SOURCES = readline.c
libguilereadline_v_@LIBGUILEREADLINE_MAJOR@_la_LIBADD = ../libguile/libguile.la
libguilereadline_v_@LIBGUILEREADLINE_MAJOR@_la_LDFLAGS = -version-info @LIBGUILEREADLINE_INTERFACE@ -export-dynamic -no-undefined

BUILT_SOURCES = readline.x

pkginclude_HEADERS = readline.h

snarfcppopts = $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
SUFFIXES = .x
.c.x:
	$(GUILE_SNARF) -o $@ $< $(snarfcppopts)

EXTRA_DIST = LIBGUILEREADLINE-VERSION ChangeLog-2008

MKDEP = gcc -M -MG $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)

CLEANFILES = *.x

dist-hook:
	(temp="/tmp/mangle-deps.$$$$"; \
	 trap "rm -f $$temp" 0 1 2 15; \
	 sed -e 's|\([ 	]\)\(\.\./\(\|libguile/\|guile-readline/\)[a-z_-]*\.h\)|\1$$(srcdir)/\2|g' $(distdir)/Makefile.in \
	 | sed -e 's|\$$(srcdir)/\(\.\./libguile/\(libpath\|scmconfig\|versiondat\)\)|\1|g' \
	 | sed -e 's|\.\./guile-readline/\([a-z_-]*\.x\)|\1|g' > $$temp \
	 && chmod u+w $(distdir)/Makefile.in && cp -p $$temp $(distdir)/Makefile.in)


code:
#!/bin/sh

[ -f readline-activator.scm ] || {
  echo "autogen.sh: run this command only in the guile-readline directory."
  exit 1
}

autoreconf -i --force


code:
AC_PREREQ(2.50)

dnl Don't use "echo -n", which is not portable (e.g., not available on
dnl MacOS X).  Instead, use `patsubst' to remove the newline.
AC_INIT(guile-readline,
        patsubst(m4_esyscmd(. ../GUILE-VERSION && echo ${GUILE_VERSION}), [
]),
	[bug-guile@gnu.org])

AC_CONFIG_AUX_DIR([.])
AC_CONFIG_SRCDIR(readline.c)
AM_CONFIG_HEADER([guile-readline-config.h])
AM_INIT_AUTOMAKE([foreign no-define])

. $srcdir/../GUILE-VERSION

AC_PROG_INSTALL
AC_PROG_CC
AM_PROG_CC_STDC
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL

dnl
dnl Check for Winsock and other functionality on Win32 (*not* CygWin)
dnl
AC_CYGWIN
AC_MINGW32
EXTRA_DEFS=""
if test "$MINGW32" = "yes" ; then
    if test $enable_shared = yes ; then
      EXTRA_DEFS="-DSCM_IMPORT"
    fi
fi
AC_SUBST(EXTRA_DEFS)

for termlib in ncurses curses termcap terminfo termlib ; do
   AC_CHECK_LIB(${termlib}, tgoto,
                [LIBS="-l${termlib} $LIBS"; break])
done

AC_CHECK_LIB(readline, readline)
if test $ac_cv_lib_readline_readline = no; then
  AC_MSG_WARN([libreadline was not found on your system.])
fi

AC_CHECK_FUNCS(siginterrupt rl_clear_signals rl_cleanup_after_signal)

dnl Check for modern readline naming
AC_CHECK_FUNCS(rl_filename_completion_function)

dnl Check for rl_get_keymap.  We only use this for deciding whether to
dnl install paren matching on the Guile command line (when using
dnl readline for input), so it's completely optional.
AC_CHECK_FUNCS(rl_get_keymap)

AC_CACHE_CHECK([for rl_getc_function pointer in readline],
		 ac_cv_var_rl_getc_function,
		 [AC_TRY_LINK([
#include <stdio.h>
#include <readline/readline.h>],
			      [printf ("%ld", (long) rl_getc_function)],
			      [ac_cv_var_rl_getc_function=yes],
			      [ac_cv_var_rl_getc_function=no])])
if test "${ac_cv_var_rl_getc_function}" = "yes"; then
  AC_DEFINE(HAVE_RL_GETC_FUNCTION, 1,
    [Define if your readline library has the rl_getc_function variable.])
fi

if test $ac_cv_lib_readline_readline = yes \
        -a $ac_cv_var_rl_getc_function = no; then
  AC_MSG_WARN([*** libreadline is too old on your system.])
  AC_MSG_WARN([*** You need readline version 2.1 or later.])
fi

AC_CHECK_FUNCS(strdup)

. $srcdir/LIBGUILEREADLINE-VERSION
AC_SUBST(LIBGUILEREADLINE_MAJOR)
AC_SUBST(LIBGUILEREADLINE_INTERFACE_CURRENT)
AC_SUBST(LIBGUILEREADLINE_INTERFACE_REVISION)
AC_SUBST(LIBGUILEREADLINE_INTERFACE_AGE)
AC_SUBST(LIBGUILEREADLINE_INTERFACE)

AC_SUBST(GUILE_EFFECTIVE_VERSION)

AC_CONFIG_FILES(Makefile ice-9/Makefile)
AC_OUTPUT


code:
## Process this file with Automake to create Makefile.in
##
##  	Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2008 Free Software Foundation, Inc.
##
##   This file is part of GUILE.
##
##   GUILE 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.
##
##   GUILE 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 GUILE; see the file COPYING.  If not, write
##   to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
##   Floor, Boston, MA 02110-1301 USA

# Guile's `pkgdatadir'.
guile_pdd = $(datadir)/guile

ice9dir = $(guile_pdd)/$(GUILE_EFFECTIVE_VERSION)/ice-9
ice9_DATA = readline.scm
ETAGS_ARGS = $(ice9_DATA)
EXTRA_DIST = $(ice9_DATA)


code:
;;;; readline.scm --- support functions for command-line editing
;;;;
;;;; 	Copyright (C) 1997, 1999, 2000, 2001, 2002, 2006 Free Software Foundation, Inc.
;;;;
;;;; This program 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.
;;;;
;;;; This program 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 this software; see the file COPYING.  If not, write to
;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;;;; Boston, MA 02110-1301 USA
;;;;
;;;; Contributed by Daniel Risacher <risacher@worldnet.att.net>.
;;;; Extensions based upon code by
;;;; Andrew Archibald <aarchiba@undergrad.math.uwaterloo.ca>.

(define-module (ice-9 readline)
  :use-module (ice-9 session)
  :use-module (ice-9 regex)
  :use-module (ice-9 buffered-input)
  :no-backtrace
  :export (filename-completion-function))

;;; Dynamically link the glue code for accessing the readline library,
;;; but only when it isn't already present.

(if (not (provided? 'readline))
    (load-extension "libguilereadline-v-17" "scm_init_readline"))

(if (not (provided? 'readline))
    (scm-error 'misc-error
	       #f
	       "readline is not provided in this Guile installation"
	       '()
	       '()))

;;; Run-time options

(export
 readline-options
 readline-enable
 readline-disable)
(export-syntax
 readline-set!)

(define-option-interface
  (readline-options-interface
   (readline-options readline-enable readline-disable)
   (readline-set!)))

;;; MDJ 980513 <djurfeldt@nada.kth.se>:
;;; There should probably be low-level support instead of this code.

;;; Dirk:FIXME:: If the-readline-port, input-port or output-port are closed,
;;; guile will enter an endless loop or crash.

(define prompt "")
(define prompt2 "")
(define input-port (current-input-port))
(define output-port (current-output-port))
(define read-hook #f)

(define (make-readline-port)
  (make-line-buffered-input-port (lambda (continuation?)
                                   (let* ((prompt (if continuation?
                                                      prompt2
                                                      prompt))
                                          (str (%readline (if (string? prompt)
                                                              prompt
                                                              (prompt))
                                                          input-port
                                                          output-port
                                                          read-hook)))
                                     (or (eof-object? str)
                                         (string=? str "")
                                         (add-history str))
                                     str))))

;;; We only create one readline port.  There's no point in having
;;; more, since they would all share the tty and history ---
;;; everything except the prompt.  And don't forget the
;;; compile/load/run phase distinctions.  Also, the readline library
;;; isn't reentrant.
(define the-readline-port #f)

(define history-variable "GUILE_HISTORY")
(define history-file (string-append (getenv "HOME") "/.guile_history"))

(define-public readline-port
  (let ((do (lambda (r/w)
	      (if (memq 'history-file (readline-options-interface))
		  (r/w (or (getenv history-variable)
			   history-file))))))
    (lambda ()
      (if (not the-readline-port)
	  (begin
	    (do read-history)
	    (set! the-readline-port (make-readline-port))
	    (add-hook! exit-hook (lambda ()
				   (do write-history)
				   (clear-history)))))
      the-readline-port)))

;;; The user might try to use readline in his programs.  It then
;;; becomes very uncomfortable that the current-input-port is the
;;; readline port...
;;;
;;; Here, we detect this situation and replace it with the
;;; underlying port.
;;;
;;; %readline is the low-level readline procedure.

(define-public (readline . args)
  (let ((prompt prompt)
	(inp input-port))
    (cond ((not (null? args))
	   (set! prompt (car args))
	   (set! args (cdr args))
	   (cond ((not (null? args))
		  (set! inp (car args))
		  (set! args (cdr args))))))
    (apply %readline
	   prompt
	   (if (eq? inp the-readline-port)
	       input-port
	       inp)
	   args)))

(define-public (set-readline-prompt! p . rest)
  (set! prompt p)
  (if (not (null? rest))
      (set! prompt2 (car rest))))

(define-public (set-readline-input-port! p)
  (cond ((or (not (file-port? p)) (not (input-port? p)))
	 (scm-error 'wrong-type-arg "set-readline-input-port!"
		    "Not a file input port: ~S" (list p) #f))
	((port-closed? p)
	 (scm-error 'misc-error "set-readline-input-port!"
		    "Port not open: ~S" (list p) #f))
	(else
	 (set! input-port p))))

(define-public (set-readline-output-port! p)
  (cond ((or (not (file-port? p)) (not (output-port? p)))
	 (scm-error 'wrong-type-arg "set-readline-input-port!"
		    "Not a file output port: ~S" (list p) #f))
	((port-closed? p)
	 (scm-error 'misc-error "set-readline-output-port!"
		    "Port not open: ~S" (list p) #f))
	(else
	 (set! output-port p))))

(define-public (set-readline-read-hook! h)
  (set! read-hook h))

(if (provided? 'regex)
    (begin
      (define-public apropos-completion-function
	(let ((completions '()))
	  (lambda (text cont?)
	    (if (not cont?)
		(set! completions
		      (map symbol->string
			   (apropos-internal
			    (string-append "^" (regexp-quote text))))))
	    (if (null? completions)
		#f
		(let ((retval (car completions)))
		  (begin (set! completions (cdr completions))
			 retval))))))

      (set! *readline-completion-function* apropos-completion-function)
      ))

(define-public (with-readline-completion-function completer thunk)
  "With @var{completer} as readline completion function, call @var{thunk}."
  (let ((old-completer *readline-completion-function*))
    (dynamic-wind
	(lambda ()
	  (set! *readline-completion-function* completer))
	thunk
	(lambda ()
	  (set! *readline-completion-function* old-completer)))))

(define-public (activate-readline)
  (if (and (isatty? (current-input-port))
	   (not (let ((guile-user-module (resolve-module '(guile-user))))
		  (and (module-defined? guile-user-module 'use-emacs-interface)
		       (module-ref guile-user-module 'use-emacs-interface)))))
      (let ((read-hook (lambda () (run-hook before-read-hook))))
	(set-current-input-port (readline-port))
	(set! repl-reader
	      (lambda (prompt)
		(dynamic-wind
		    (lambda ()
                      (set-buffered-input-continuation?! (readline-port) #f)
		      (set-readline-prompt! prompt "... ")
		      (set-readline-read-hook! read-hook))
		    (lambda () (read))
		    (lambda ()
		      (set-readline-prompt! "" "")
		      (set-readline-read-hook! #f)))))
	(set! (using-readline?) #t))))

(define-public (make-completion-function strings)
  "Construct and return a completion function for a list of strings.
The returned function is suitable for passing to
@code{with-readline-completion-function.  The argument @var{strings}
should be a list of strings, where each string is one of the possible
completions."
  (letrec ((strs '())
	   (regexp #f)
	   (completer (lambda (text continue?)
			(if continue?
			    (if (null? strs)
				#f
				(let ((str (car strs)))
				  (set! strs (cdr strs))
				  (if (string-match regexp str)
				      str
				      (completer text #t))))
			    (begin
			      (set! strs strings)
			      (set! regexp
				    (string-append "^" (regexp-quote text)))
			      (completer text #t))))))
    completer))


code:
(define-module (readline-activator))

(define-public (activate-readline)
  (if (not (provided? 'readline))
      (scm-error 'misc-error
		 'activate-readline
		 "readline is not provided in this Guile installation"
		 '()
		 '()))
  (save-module-excursion
   (lambda ()
     (define-module (guile))
     (dynamic-call "scm_init_readline" (dynamic-link "libguilereadline.so"))
     (if (isatty? (current-input-port))
	 (begin
	   (define-module (guile) :use-module (ice-9 readline))
	   (define-module (guile-user) :use-module (ice-9 readline)))))))


code:
/* readline.c --- line editing support for Guile */

/* Copyright (C) 1997,1999,2000,2001, 2002, 2003, 2006, 2007, 2008 Free Software Foundation, Inc.
 *
 * This program 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.
 *
 * This program 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 this software; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA
 *
 */

/* Include private, configure generated header (i.e. config.h). */
#include "guile-readline-config.h"

#ifdef HAVE_RL_GETC_FUNCTION
#include "libguile.h"
#include "libguile/gh.h"
#include "libguile/iselect.h"

#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <readline/readline.h>
#include <readline/history.h>
#ifndef __MINGW32__
#include <sys/time.h>
#else
#include <io.h>
#endif
#include <signal.h>

#include "libguile/validate.h"
#include "guile-readline/readline.h"

scm_t_option scm_readline_opts[] = {
  { SCM_OPTION_BOOLEAN, "history-file", 1,
    "Use history file." },
  { SCM_OPTION_INTEGER, "history-length", 200,
    "History length." },
  { SCM_OPTION_INTEGER, "bounce-parens", 500,
    "Time (ms) to show matching opening parenthesis (0 = off)."}
};

extern void stifle_history (int max);

SCM_DEFINE (scm_readline_options, "readline-options-interface", 0, 1, 0,
            (SCM setting),
"")
#define FUNC_NAME s_scm_readline_options
{
  SCM ans = scm_options (setting,
			 scm_readline_opts,
			 SCM_N_READLINE_OPTIONS,
			 FUNC_NAME);
  stifle_history (SCM_HISTORY_LENGTH);
  return ans;
}
#undef FUNC_NAME

#ifndef HAVE_STRDUP
static char *
strdup (char *s)
{
  size_t len = strlen (s);
  char *new = malloc (len + 1);
  strcpy (new, s);
  return new;
}
#endif /* HAVE_STRDUP */

#ifndef HAVE_RL_CLEANUP_AFTER_SIGNAL

/* These are readline functions added in release 2.3.  They will work
 * together with readline-2.1 and 2.2.  (The readline interface is
 * disabled for earlier releases.)
 * They are declared static; if we want to use them elsewhere, then
 * we need external declarations for them, but at the moment, I don't
 * think anything else in Guile ought to use these.
 */

extern void _rl_clean_up_for_exit ();
extern void _rl_kill_kbd_macro ();
extern int _rl_init_argument ();

void
rl_cleanup_after_signal ()
{
#ifdef HAVE_RL_CLEAR_SIGNALS
  _rl_clean_up_for_exit ();
#endif
  (*rl_deprep_term_function) ();
#ifdef HAVE_RL_CLEAR_SIGNALS
  rl_clear_signals ();
#endif
  rl_pending_input = 0;
}

void
rl_free_line_state ()
{
  register HIST_ENTRY *entry;

  free_undo_list ();

  entry = current_history ();
  if (entry)
    entry->data = (char *)NULL;

  _rl_kill_kbd_macro ();
  rl_clear_message ();
  _rl_init_argument ();
}

#endif /* !HAVE_RL_CLEANUP_AFTER_SIGNAL */

static int promptp;
static SCM input_port;
static SCM before_read;

static int
current_input_getc (FILE *in SCM_UNUSED)
{
  if (promptp && scm_is_true (before_read))
    {
      scm_apply (before_read, SCM_EOL, SCM_EOL);
      promptp = 0;
    }
  return scm_getc (input_port);
}

static int in_readline = 0;
static SCM reentry_barrier_mutex;

static SCM internal_readline (SCM text);
static SCM handle_error (void *data, SCM tag, SCM args);
static void reentry_barrier (void);

SCM_DEFINE (scm_readline, "%readline", 0, 4, 0,
            (SCM text, SCM inp, SCM outp, SCM read_hook),
"")
#define FUNC_NAME s_scm_readline
{
  SCM ans;

  reentry_barrier ();

  before_read = SCM_BOOL_F;

  if (!SCM_UNBNDP (text))
    {
      if (!scm_is_string (text))
	{
	  --in_readline;
	  scm_wrong_type_arg (s_scm_readline, SCM_ARG1, text);
	}
    }

  if (!((SCM_UNBNDP (inp) && SCM_OPINFPORTP (scm_current_input_port ()))
	|| SCM_OPINFPORTP (inp)))
    {
      --in_readline;
      scm_misc_error (s_scm_readline,
		      "Input port is not open or not a file port",
		      SCM_EOL);
    }

  if (!((SCM_UNBNDP (outp) && SCM_OPOUTFPORTP (scm_current_output_port ()))
	|| SCM_OPOUTFPORTP (outp)))
    {
      --in_readline;
      scm_misc_error (s_scm_readline,
		      "Output port is not open or not a file port",
		      SCM_EOL);
    }

  if (!(SCM_UNBNDP (read_hook) || scm_is_false (read_hook)))
    {
      if (scm_is_false (scm_thunk_p (read_hook)))
	{
	  --in_readline;
	  scm_wrong_type_arg (s_scm_readline, SCM_ARG4, read_hook);
	}
      before_read = read_hook;
    }

  scm_readline_init_ports (inp, outp);

  ans = scm_internal_catch (SCM_BOOL_T,
			    (scm_t_catch_body) internal_readline,
			    (void *) SCM_UNPACK (text),
			    handle_error, 0);

#ifndef __MINGW32__
  fclose (rl_instream);
  fclose (rl_outstream);
#endif

  --in_readline;
  return ans;
}
#undef FUNC_NAME

static void
reentry_barrier ()
{
  int reentryp = 0;
  /* We should rather use scm_try_mutex when it becomes available */
  scm_lock_mutex (reentry_barrier_mutex);
  if (in_readline)
    reentryp = 1;
  else
    ++in_readline;
  scm_unlock_mutex (reentry_barrier_mutex);
  if (reentryp)
    scm_misc_error (s_scm_readline, "readline is not reentrant", SCM_EOL);
}

static SCM
handle_error (void *data, SCM tag, SCM args)
{
  rl_free_line_state ();
  rl_cleanup_after_signal ();
  fputc ('\n', rl_outstream); /* We don't want next output on this line */
#ifndef __MINGW32__
  fclose (rl_instream);
  fclose (rl_outstream);
#endif
  --in_readline;
  scm_handle_by_throw (data, tag, args);
  return SCM_UNSPECIFIED; /* never reached */
}

static SCM
internal_readline (SCM text)
{
  SCM ret;
  char *s;
  char *prompt = SCM_UNBNDP (text) ? "" : scm_to_locale_string (text);

  promptp = 1;
  s = readline (prompt);
  if (s)
    ret = scm_from_locale_string (s);
  else
    ret = SCM_EOF_VAL;

  if (!SCM_UNBNDP (text))
    free (prompt);
  free (s);

  return ret;
}

static FILE *
stream_from_fport (SCM port, char *mode, const char *subr)
{
  int fd;
  FILE *f;

  fd = dup (((struct scm_t_fport *) SCM_STREAM (port))->fdes);
  if (fd == -1)
    {
      --in_readline;
      scm_syserror (subr);
    }

  f = fdopen (fd, mode);
  if (f == NULL)
    {
      --in_readline;
      scm_syserror (subr);
    }

  return f;
}

void
scm_readline_init_ports (SCM inp, SCM outp)
{
  if (SCM_UNBNDP (inp))
    inp = scm_current_input_port ();

  if (SCM_UNBNDP (outp))
    outp = scm_current_output_port ();

  if (!SCM_OPINFPORTP (inp)) {
    scm_misc_error (0,
                    "Input port is not open or not a file port",
                    SCM_EOL);
  }

  if (!SCM_OPOUTFPORTP (outp)) {
    scm_misc_error (0,
                    "Output port is not open or not a file port",
                    SCM_EOL);
  }

  input_port = inp;
#ifndef __MINGW32__
  rl_instream = stream_from_fport (inp, "r", s_scm_readline);
  rl_outstream = stream_from_fport (outp, "w", s_scm_readline);
#endif
}

SCM_DEFINE (scm_add_history, "add-history", 1, 0, 0,
            (SCM text),
"")
#define FUNC_NAME s_scm_add_history
{
  char* s;

  s = scm_to_locale_string (text);
  add_history (s);
  free (s);

  return SCM_UNSPECIFIED;
}
#undef FUNC_NAME

SCM_DEFINE (scm_read_history, "read-history", 1, 0, 0,
            (SCM file),
"")
#define FUNC_NAME s_scm_read_history
{
  char *filename;
  SCM ret;

  filename = scm_to_locale_string (file);
  ret = scm_from_bool (!read_history (filename));
  free (filename);
  return ret;
}
#undef FUNC_NAME

SCM_DEFINE (scm_write_history, "write-history", 1, 0, 0,
            (SCM file),
"")
#define FUNC_NAME s_scm_write_history
{
  char *filename;
  SCM ret;

  filename = scm_to_locale_string (file);
  ret = scm_from_bool (!write_history (filename));
  free (filename);
  return ret;
}
#undef FUNC_NAME

SCM_DEFINE (scm_clear_history, "clear-history", 0, 0, 0,
            (),
	    "Clear the history buffer of the readline machinery.")
#define FUNC_NAME s_scm_clear_history
{
  clear_history();
  return SCM_UNSPECIFIED;
}
#undef FUNC_NAME

SCM_DEFINE (scm_filename_completion_function, "filename-completion-function", 2, 0, 0,
            (SCM text, SCM continuep),
"")
#define FUNC_NAME s_scm_filename_completion_function
{
  char *s;
  SCM ans;
  char *c_text = scm_to_locale_string (text);
#ifdef HAVE_RL_FILENAME_COMPLETION_FUNCTION
  s = rl_filename_completion_function (c_text, scm_is_true (continuep));
#else
  s = filename_completion_function (c_text, scm_is_true (continuep));
#endif
  ans = scm_take_locale_string (s);
  free (c_text);
  return ans;
}
#undef FUNC_NAME

/*
 * The following has been modified from code contributed by
 * Andrew Archibald <aarchiba@undergrad.math.uwaterloo.ca>
 */

SCM scm_readline_completion_function_var;

static char *
completion_function (char *text, int continuep)
{
  SCM compfunc = SCM_VARIABLE_REF (scm_readline_completion_function_var);
  SCM res;

  if (scm_is_false (compfunc))
    return NULL; /* #f => completion disabled */
  else
    {
      SCM t = scm_from_locale_string (text);
      SCM c = scm_from_bool (continuep);
      res = scm_apply (compfunc, scm_list_2 (t, c), SCM_EOL);

      if (scm_is_false (res))
	return NULL;

      return scm_to_locale_string (res);
    }
}

#if HAVE_RL_GET_KEYMAP
/*Bouncing parenthesis (reimplemented by GH, 11/23/98, since readline is strict gpl)*/

static int match_paren (int x, int k);
static int find_matching_paren (int k);
static void init_bouncing_parens ();

static void
init_bouncing_parens ()
{
  if (strncmp (rl_get_keymap_name (rl_get_keymap ()), "vi", 2))
    {
      rl_bind_key (')', match_paren);
      rl_bind_key (']', match_paren);
      rl_bind_key ('}', match_paren);
    }
}

static int
find_matching_paren(int k)
{
  register int i;
  register char c = 0;
  int end_parens_found = 0;

  /* Choose the corresponding opening bracket.  */
  if (k == ')') c = '(';
  else if (k == ']') c = '[';
  else if (k == '}') c = '{';

  for (i=rl_point-2; i>=0; i--)
    {
      /* Is the current character part of a character literal?  */
      if (i - 2 >= 0
	  && rl_line_buffer[i - 1] == '\\'
	  && rl_line_buffer[i - 2] == '#')
	;
      else if (rl_line_buffer[i] == k)
	end_parens_found++;
      else if (rl_line_buffer[i] == '"')
	{
	  /* Skip over a string literal.  */
	  for (i--; i >= 0; i--)
	    if (rl_line_buffer[i] == '"'
		&& ! (i - 1 >= 0
		      && rl_line_buffer[i - 1] == '\\'))
	      break;
	}
      else if (rl_line_buffer[i] == c)
	{
	  if (end_parens_found==0)
	    return i;
	  else --end_parens_found;
	}
    }
  return -1;
}

static int
match_paren (int x, int k)
{
  int tmp;
#ifndef __MINGW32__
  int fno;
  SELECT_TYPE readset;
  struct timeval timeout;
#endif

  rl_insert (x, k);
  if (!SCM_READLINE_BOUNCE_PARENS)
    return 0;

  /* Did we just insert a quoted paren?  If so, then don't bounce.  */
  if (rl_point - 1 >= 1
      && rl_line_buffer[rl_point - 2] == '\\')
    return 0;

#ifndef __MINGW32__
  tmp = 1000 * SCM_READLINE_BOUNCE_PARENS;
  timeout.tv_sec = tmp / 1000000;
  timeout.tv_usec = tmp % 1000000;
  FD_ZERO (&readset);
  fno = fileno (rl_instream);
  FD_SET (fno, &readset);
#endif

  if (rl_point > 1)
    {
      tmp = rl_point;
      rl_point = find_matching_paren (k);
      if (rl_point > -1)
	{
	  rl_redisplay ();
#ifndef __MINGW32__
	  scm_std_select (fno + 1, &readset, NULL, NULL, &timeout);
#else
	  WaitForSingleObject (GetStdHandle(STD_INPUT_HANDLE),
			       SCM_READLINE_BOUNCE_PARENS);
#endif
	}
      rl_point = tmp;
    }
  return 0;
}
#endif /* HAVE_RL_GET_KEYMAP */

#endif /* HAVE_RL_GETC_FUNCTION */

void
scm_init_readline ()
{
#ifdef HAVE_RL_GETC_FUNCTION
#include "guile-readline/readline.x"
  scm_readline_completion_function_var
    = scm_c_define ("*readline-completion-function*", SCM_BOOL_F);
#ifndef __MINGW32__
  rl_getc_function = current_input_getc;
#endif
#if defined (_RL_FUNCTION_TYPEDEF)
  rl_completion_entry_function = (rl_compentry_func_t*) completion_function;
#else
  rl_completion_entry_function = (Function*) completion_function;
#endif
  rl_basic_word_break_characters = "\t\n\"'`;()";
  rl_readline_name = "Guile";

  reentry_barrier_mutex = scm_permanent_object (scm_make_mutex ());
  scm_init_opts (scm_readline_options,
		 scm_readline_opts,
		 SCM_N_READLINE_OPTIONS);
#if HAVE_RL_GET_KEYMAP
  init_bouncing_parens();
#endif
  scm_add_feature ("readline");
#endif /* HAVE_RL_GETC_FUNCTION */
}

/*
  Local Variables:
  c-file-style: "gnu"
  End:
*/


code:
#ifndef READLINEH
#define READLINEH

/*	Copyright (C) 1997, 1999, 2000, 2006 Free Software Foundation, Inc.
 *
 * This program 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.
 *
 * This program 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 this software; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA
 *
 */

/* SCM_RL_API is a macro prepended to all function and data definitions
   which should be exported or imported in the resulting dynamic link
   library in the Win32 port. */

#if defined (SCM_RL_IMPORT)
# define SCM_RL_API __declspec (dllimport) extern
#elif defined (SCM_RL_EXPORT) || defined (DLL_EXPORT)
# define SCM_RL_API __declspec (dllexport) extern
#else
# define SCM_RL_API extern
#endif

#include "libguile/__scm.h"

SCM_RL_API scm_t_option scm_readline_opts[];

#define SCM_HISTORY_FILE_P     scm_readline_opts[0].val
#define SCM_HISTORY_LENGTH     scm_readline_opts[1].val
#define SCM_READLINE_BOUNCE_PARENS scm_readline_opts[2].val
#define SCM_N_READLINE_OPTIONS 3

SCM_RL_API SCM scm_readline_options (SCM setting);
SCM_RL_API void scm_readline_init_ports (SCM inp, SCM outp);
SCM_RL_API SCM scm_readline (SCM txt, SCM inp, SCM outp, SCM read_hook);
SCM_RL_API SCM scm_add_history (SCM txt);
SCM_RL_API SCM scm_clear_history (void);
SCM_RL_API SCM scm_read_history (SCM file);
SCM_RL_API SCM scm_write_history (SCM file);
SCM_RL_API SCM scm_filename_completion_function (SCM text, SCM continuep);
SCM_RL_API void scm_init_readline (void);

#ifndef HAVE_RL_CLEANUP_AFTER_SIGNAL
void rl_cleanup_after_signal ();
void rl_free_line_state ();
#endif

#endif

/*
  Local Variables:
  c-file-style: "gnu"
  End:
*/


code:
#!/bin/sh

# 	Copyright (C) 2001, 2003, 2006, 2008 Free Software Foundation, Inc.
#
# This program 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.
#
# This program 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 this software; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA

# Usage: See `help' func below.
#
# TODO
# - handle pre-install invocation
# - "full" option processing (but see comment below)
#
# Author: Thien-Thi Nguyen

help ()
{
    cat <<EOF
Usage: guile-tools --version
       guile-tools --help
       guile-tools [OPTION] PROGRAM [ARGS]

If PROGRAM is "list" or omitted, display contents of scripts dir, otherwise
PROGRAM is run w/ ARGS.  Options (only one of which may be used at a time):
 --scriptsdir DIR    -- Look in DIR for scripts
 --guileversion VERS -- Look in $pkgdatadir/VERS/scripts for scripts
 --source            -- Display PROGRAM source (ignore ARGS) to stdout

Default scripts dir: $default_scriptsdir
EOF
}

prefix="@prefix@"
datarootdir="@datarootdir@"
pkgdatadir="@datadir@/@PACKAGE@"
guileversion="@GUILE_EFFECTIVE_VERSION@"
default_scriptsdir=$pkgdatadir/$guileversion/scripts

# pre-install invocation frob
mydir=`dirname $0`
if [ -d "$mydir/scripts" -a -f "$mydir/scripts/Makefile.am" ] ; then
    default_scriptsdir=`(cd $mydir/scripts ; pwd)`
fi

# option processing -- basically, you can override either the script dir
# completely, or just the guile version.  we choose implementation simplicity
# over orthogonality.

case x"$1" in
x--version)
    echo $0 $guileversion
    exit 0
    ;;
x--help)
    help
    exit 0
    ;;
esac

if [ x"$1" = x--scriptsdir ] ; then
    user_scriptsdir=$2
    shift
    shift
elif [ x"$1" = x--guileversion ] ; then
    user_scriptsdir=$pkgdatadir/$2/scripts
    shift
    shift
fi

scriptsdir=${user_scriptsdir-$default_scriptsdir}

if [ ! -d $scriptsdir ] ; then
    echo $0: no such directory: $scriptsdir
    exit 1
fi

if [ x"$1" = x -o x"$1" = xlist ] ; then
    ls $scriptsdir
    exit 0
fi

if [ x"$1" = x--source ] ; then
    if [ x"$2" = x ] ; then echo $0: need to specify program ; exit 1 ; fi
    if [ -x $scriptsdir/$2 ] ; then
        cat $scriptsdir/$2
        exit 0
    else
        echo $0: no such program: $2
        exit 1
    fi
fi

program=$scriptsdir/$1
shift

if [ -x $program ] ; then
    exec $program "$@"
else
    echo $0: no such program: $program
    exit 1
fi

# guile-tools ends here