Guile comes with an interface module to the readline library. This
makes interactive use much more convenient, because of the command-line
editing features of readline. Using (ice-9 readline), you can
navigate through the current input line with the cursor keys, retrieve
older command lines from the input history and even search through the
history entries.
The module is not loaded by default and so has to be loaded and activated explicitly. This is done with two simple lines of code:
(use-modules (ice-9 readline)) (activate-readline)
The first line will load the necessary code, and the second will activate readline's features for the REPL. If you plan to use this module often, you should save these to lines to your `.guile' personal startup file.
You will notice that the REPL's behaviour changes a bit when you have
loaded the readline module. For example, when you press Enter before
typing in the closing parentheses of a list, you will see the
continuation prompt, three dots: ... This gives you a nice
visual feedback when trying to match parentheses. To make this even
easier, bouncing parentheses are implemented. That means that
when you type in a closing parentheses, the cursor will jump to the
corresponding opening parenthesis for a short time, making it trivial to make
them match.
Once the readline module is activated, all lines entered interactively will be stored in a history and can be recalled later using the cursor-up and -down keys. Readline also understands the Emacs keys for navigating through the command line and history.
When you quit your Guile session by evaluating (quit) or pressing
Ctrl-D, the history will be saved to the file `.guile_history' and
read in when you start Guile for the next time. Thus you can start a
new Guile session and still have the (probably long-winded) definition
expressions available.
The readline interface module can be configured in several ways to better suit the user's needs. Configuration is done via the readline module's options interface, in a similar way to the evaluator and debugging options (see section General option interface.)
Here is the list of readline options generated by typing
(readline-options 'full) in Guile. You can also see the
default values.
bounce-parens 500 Time (ms) to show matching opening parenthesis (0 = off). history-length 200 History length. history-file yes Use history file.
The history length specifies how many input lines will be remembered. If the history contains that many lines and additional lines are entered, the oldest lines will be lost. You can switch on/off the usage of the history file using the following call.
(readline-disable 'history)
The readline options interface can only be used after loading the readline module, because it is defined in that module.
Go to the first, previous, next, last section, table of contents.