Note: This is taken from the Chicken Wiki, where a more recent version could be available.
A binding for the GNU readline library.
[procedure] (gnu-readline PROMPT)
Reads a line using the GNU readline() function and returns a string. PROMPT should also be a string.
Clears the history buffer.
[procedure] (gnu-readline-read-history FILENAME)
Reads the history buffer from the file FILENAME (or ~/.history if FILENAME is #f). Returns 0 on success.
[procedure] (gnu-readline-write-history FILENAME)
Writes the history buffer to the file FILENAME (or ~/.history if FILENAME is #f). Returns 0 on success. Do not use unless you want to clobber simultaneous sessions.
[procedure] (gnu-readline-append-history FILENAME)
Appends only the new entries to FILENAME.
Returns the number of new entries (input lines from this session).
[procedure] (gnu-readline-truncate-history FILENAME NUMLINES)
Truncates the history file FILENAME (or ~/.history if FILENAME is #f) to NUMLINES lines. Returns 0 on success.
[procedure] (gnu-history-install-file-manager FILENAME [NUMLINES])
If you also want to make the command history span sessions, add the following:
(gnu-history-install-file-manager (string-append (or (getenv "HOME") ".") "/.csi.history"))
By default this will save 1000 lines of history between sessions (it will prune the history file to 1000 lines at startup). For a different history size, pass the desired number of lines as the (optional) second argument to gnu-history-install-file-manager. If #f is passed in, no history-file-pruning will take place.
[procedure] (make-gnu-readline-port [PROMPT] [PROMPT2])
Returns an input-port that uses the GNU readline facility. If PROMPT is not given, the value returned by (repl-prompt) is used for generating the current prompt (see the Chicken manual for more details about repl-prompt). PROMPT2 is used when there are still unclosed parenthesis; if not given, an appropriate default is generated.
[procedure] (gnu-readline-set-bounce-ms TIME)
Changes the time that the cursor spends bouncing on the matching parenthesis - the default 500ms. To turn bouncing off completely, set to zero.
[procedure] (gnu-readline-parse-and-bind CONFIG)
Passes string CONFIG straight to the readline library for parsing (see the readline manual page for details). This extension supports static linking.
% csi -quiet #;1> (require 'readline) #;2> (current-input-port (make-gnu-readline-port)) #;3>
To get csi to keep a history use the following (in your ~/.csirc file):
(require 'readline 'regex) (current-input-port (make-gnu-readline-port)) (gnu-history-install-file-manager (string-append (or (getenv "HOME") ".") "/.csi.history"))
To set readline to behave somewhat like vi:
(gnu-readline-parse-and-bind "set editing-mode vi")
This extension requires GNU readline. You will receive errors if you don't have the C header files for your readline installation or if you use some versions of the BSD readline alternative, libedit.
In particular, Mac OS X versions prior to 10.5 Leopard ship with /usr/lib/libreadline.dylib linked to an older libedit, causing the following error when you install this egg:
/usr/bin/ld: Undefined symbols: _history_truncate_file
To fix this, install a copy of GNU readline in /usr/local/lib or, if you're using MacPorts, symlink it:
ln -s /opt/local/lib/libreadline.dylib /usr/local/lib
Do not modify the readline link in /usr/lib.
MacOS X 10.5.2 again causes errors when building this egg. Installing MacPorts and doing the symlink above fixes the problem.
In the case of Debian, you should probably install the package libreadline-dev, which is not installed by default.
Copyright (c) 2002 Tony Garnock-Jones Copyright (c) 2006 Heath Johns (paren bouncing and auto-completion code) 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 of the License, 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 program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA