Scheme readline completion
When interacting with a REPL, readline history and tab completion support are major productivity boosters. This is true in general, but especially so given Scheme’s long names (e.g. call-with-input-file
). Some Schemes have integrated readline support, but the one I use most, namely SISC, does not.
The next best thing is to use something like rlwrap (as SISC actually does). «rlwrap COMMAND» adds history support out of the box by intercepting COMMAND’s standard input and output. Furthermore, I’ve just learned that, when configured properly, rlwrap can also autocomplete a predefined set of identifiers (and optionally learn new identifiers from standard input/output). SISC does not enable completion by default, but we can easily fix it. The relevant command-line arguments are
- -b DELIMITER-CHARS
- A list of word-separating delimiters. Whitespace is included by default; for Scheme, use “\”()[]’`”.
- -H HISTORY-file
- The history file.
- -f IDENTIFIER-FILE
- A file listing the identifiers to be completed by default, one per line (this option can occur multiple times). I wrote a script to parse the R5RS index HTML page; I’m putting the output online, so you can simply download the resulting R5RS identifier list. It makes sense to also add a -f HISTORY-FILE argument.
These are the basics; the man page documents a few more interesting options (in particular, see -r). Using rlwrap, you can enable readline history and completion for any interaction-challenged Scheme system.