source: project/wiki/readline @ 6296

Last change on this file since 6296 was 6296, checked in by svnwiki, 13 years ago

Changes applied for Anonymous (69.12.162.76) through svnwiki:

File size: 4.7 KB
Line 
1[[tags: egg]]
2[[toc:]]
3
4== readline
5
6A binding for the GNU readline library.
7
8== Interface
9
10 [procedure] (gnu-readline PROMPT)
11Reads a line using the GNU readline() function and returns a string. PROMPT should also be a string.
12 [procedure] (gnu-readline-clear-history)
13Clears the history buffer.
14 [procedure] (gnu-readline-read-history FILENAME)
15Reads the history buffer from the file FILENAME (or ~/.history if FILENAME is #f). Returns 0 on success.
16 [procedure] (gnu-readline-write-history FILENAME)
17Writes the history buffer to the file FILENAME (or ~/.history if FILENAME is #f). Returns 0 on success.
18 [procedure] (gnu-readline-truncate-history FILENAME NUMLINES)
19Truncates the history file FILENAME (or ~/.history if FILENAME is #f) to NUMLINES lines. Returns 0 on success.
20 [procedure] (gnu-history-install-file-manager FILENAME [NUMLINES])
21If you also want to make the command history span sessions, add the following:
22
23{{(gnu-history-install-file-manager (string-append (or (getenv "HOME") ".") "/.csi.history"))}}
24
25By 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.
26 [procedure] (make-gnu-readline-port [PROMPT] [PROMPT2])
27Returns 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.
28 [procedure] (gnu-readline-set-bounce-ms TIME)
29Changes the time that the cursor spends bouncing on the matching parenthesis - the default 500ms. To turn bouncing off completely, set to zero.
30 [procedure] (gnu-readline-parse-and-bind CONFIG)
31Passes string CONFIG straight to the readline library for parsing (see the readline manual page for details).
32This extension supports static linking.
33
34== Examples
35
36 % csi -quiet
37 >>> (require 'readline)
38 >>> (current-input-port (make-gnu-readline-port "csi> "))
39 csi>
40
41To get csi to keep a history use the following (in your ~/.csirc file):
42 (require 'readline 'regex)
43 (current-input-port (make-gnu-readline-port))
44 (gnu-history-install-file-manager (string-append (or (getenv "HOME") ".") "/.csi.history"))
45
46To set readline to behave somewhat like vi:
47 (gnu-readline-parse-and-bind "set editing-mode vi")
48
49== Installation problems
50
51This extension requires GNU readline.  You will receive errors if you use some versions of the BSD readline alternative, libedit.
52
53In 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:
54
55 /usr/bin/ld: Undefined symbols:
56 _history_truncate_file
57
58To fix this, install a copy of GNU readline in {{/usr/local/lib}} or, if you're using MacPorts, symlink it:
59
60 ln -s /opt/local/lib/libreadline.dylib /usr/local/lib
61
62Do ''not'' modify the readline link in {{/usr/lib}}.
63
64== About this egg
65
66=== Author
67
68Tony Garnock-Jones
69
70=== Version history
71
72; 1.91 : Added support for static linking [felix]
73; 1.9 : Ignores duplicate history entries [Thanks to Toby Butzon]
74; 1.8 : Empty lines are not added to history [Thanks to Dan Muresan]
75; 1.7 : Added parenthesis bouncing, a new auto-complete [Heath Johns]
76; 1.6 : Export *completion-entry-function* to support autocomplete [Alejandro Forero Cuervo]
77; 1.5 : prompt argument to make-gnu-readline-port is optional [felix]
78; 1.4 : Replaced use of (end-of-file) with #!eof
79; 1.3 : Checks more possible libraries to link with at build time [Thanks to Peter Bex]
80; 1.2 : Adapted to new setup scheme.
81; 1.1 : More features, changed license to GPL, links with either libtermcap or libncurses.
82; 1.0 : Initial release
83
84=== License
85
86 Copyright (c) 2002 Tony Garnock-Jones
87 Copyright (c) 2006 Heath Johns (paren bouncing and auto-completion code)
88 
89 This program is free software; you can redistribute it and/or modify
90 it under the terms of the GNU General Public License as published by
91 the Free Software Foundation; either version 2 of the License, or
92 (at your option) any later version.
93 
94 This program is distributed in the hope that it will be useful,
95 but WITHOUT ANY WARRANTY; without even the implied warranty of
96 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
97 GNU General Public License for more details.
98 
99 You should have received a copy of the GNU General Public License
100 along with this program; if not, write to the Free Software
101 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
102
Note: See TracBrowser for help on using the repository browser.