Next: , Up: Readline Support

6.5.1 Loading Readline Support

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))

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.

You can specify a different history file by setting the environment variable GUILE_HISTORY. And you can make Guile specific customizations to your .inputrc by testing for application ‘Guile’ (see Conditional Init Constructs). For instance to define a key inserting a matched pair of parentheses,

     $if Guile
       "\C-o": "()\C-b"