* eval.c (scm_unmemocopy): Fixed unmemoization of let*.
[bpt/guile.git] / doc / ref / repl-modules.texi
CommitLineData
2da09c3f
MV
1@c -*-texinfo-*-
2@c This is part of the GNU Guile Reference Manual.
3@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004
4@c Free Software Foundation, Inc.
5@c See the file guile.texi for copying conditions.
6
a0e07ba4
NJ
7@page
8@node Readline Support
9@chapter Readline Support
10
11@c FIXME::martin: Review me!
12
13@cindex readline
14@cindex command line history
15Guile comes with an interface module to the readline library. This
16makes interactive use much more convenient, because of the command-line
17editing features of readline. Using @code{(ice-9 readline)}, you can
18navigate through the current input line with the cursor keys, retrieve
19older command lines from the input history and even search through the
20history entries.
21
22@menu
23* Loading Readline Support:: How to load readline support into Guile.
24* Readline Options:: How to modify readline's behaviour.
25@end menu
26
27
28@node Loading Readline Support
29@section Loading Readline Support
30
31The module is not loaded by default and so has to be loaded and
32activated explicitly. This is done with two simple lines of code:
33
4b83d327 34@findex activate-readline
a0e07ba4
NJ
35@lisp
36(use-modules (ice-9 readline))
37(activate-readline)
38@end lisp
39
40@c FIXME::martin: Review me!
41
42The first line will load the necessary code, and the second will
43activate readline's features for the REPL. If you plan to use this
44module often, you should save these to lines to your @file{.guile}
45personal startup file.
46
47You will notice that the REPL's behaviour changes a bit when you have
85a9b4ed 48loaded the readline module. For example, when you press Enter before
a0e07ba4
NJ
49typing in the closing parentheses of a list, you will see the
50@dfn{continuation} prompt, three dots: @code{...} This gives you a nice
51visual feedback when trying to match parentheses. To make this even
52easier, @dfn{bouncing parentheses} are implemented. That means that
53when you type in a closing parentheses, the cursor will jump to the
85a9b4ed 54corresponding opening parenthesis for a short time, making it trivial to make
a0e07ba4
NJ
55them match.
56
57Once the readline module is activated, all lines entered interactively
58will be stored in a history and can be recalled later using the
59cursor-up and -down keys. Readline also understands the Emacs keys for
60navigating through the command line and history.
61
62When you quit your Guile session by evaluating @code{(quit)} or pressing
63Ctrl-D, the history will be saved to the file @file{.guile_history} and
64read in when you start Guile for the next time. Thus you can start a
65new Guile session and still have the (probably long-winded) definition
66expressions available.
67
68
69@node Readline Options
70@section Readline Options
71
72@c FIXME::martin: Review me!
73
74@cindex readline options
75The readline interface module can be configured in several ways to
76better suit the user's needs. Configuration is done via the readline
77module's options interface, in a similar way to the evaluator and
c936bede 78debugging options (@pxref{User level options interfaces}.)
a0e07ba4 79
4b83d327
KR
80@findex readline-options
81@findex readline-enable
82@findex readline-disable
83@findex readline-set!
a0e07ba4
NJ
84Here is the list of readline options generated by typing
85@code{(readline-options 'full)} in Guile. You can also see the
86default values.
87
88@smalllisp
89bounce-parens 500 Time (ms) to show matching opening parenthesis (0 = off).
90history-length 200 History length.
91history-file yes Use history file.
92@end smalllisp
93
94The history length specifies how many input lines will be remembered.
95If the history contains that many lines and additional lines are
96entered, the oldest lines will be lost. You can switch on/off the
97usage of the history file using the following call.
98
99@lisp
100(readline-disable 'history)
101@end lisp
102
103The readline options interface can only be used @emph{after} loading
104the readline module, because it is defined in that module.
105
106
107@page
108@node Value History
109@chapter Value History
110
111@c FIXME::martin: Review me!
112
113@cindex value history
114Another module which makes command line usage more convenient is
115@code{(ice-9 history)}. This module will change the REPL so that each
116value which is evaluated and printed will be remembered under a name
117constructed from the dollar character (@code{$}) and the number of the
118evaluated expression.
119
120Consider an example session.
121
122@example
123guile> (use-modules (ice-9 history))
124guile> 1
125$1 = 1
126guile> (+ $1 $1)
127$2 = 2
128guile> (* $2 $2)
129$3 = 4
130@end example
131
132After loading the value history module @code{(ice-9 history)}, one
133(trivial) expression is evaluated. The result is stored into the
134variable @code{$1}. This fact is indicated by the output @code{$1 = },
135which is also caused by @code{(ice-9 history)}. In the next line, this
136variable is used two times, to produce the value @code{$2}, which in
137turn is used in the calculation for @code{$3}.
138
139
140@c Local Variables:
141@c TeX-master: "guile.texi"
142@c End: