Spice Up the Chicken REPL with Linenoise

In this post I want to point you to way technique to add some missing features to the Chicken Scheme REPL.

If you aren't too familiar with Chicken Scheme you start the REPL like this.

csi

This actually runs the chicken scheme interpreter but on user input instead of a .scm file. One thing you'll notice is that there is no command history. Essentially, what we need is readline. For a while I suffered through this until I was looking through different eggs and linenoise. This means we don't actually need readline.

Linenoise is cool because it provides a minimalist alternative to the readline library. You can add this functionality to the REPL by going through these steps.

You'll first need to install the linenoise egg.

chicken-install linenoise

Then we need to add this to our .csirc located in our $HOME directory. You'll need to create it if it doesn't exist already. Then add these lines to the file:

(import linenoise)
(current-input-port (make-linenoise-port))

Now the next time you run csi you'll be able to navigate the REPL lines and history with the arrow keys. Voila! A much tastier version of the chicken interpreter!

Happy scheming :p

Content for this site is CC-BY-SA.

More Posts