Intro
Tooling around with my Nook, I discovered a bug in Sigil, an ePub editor. Whenever a user toggles between the HTML code section and the book view section, a newline is inserted before every PRE tag. This means every code block in an ebook gets shoved way down the page. I thought that’s not so bad, filed a bug report, and began manually undoing those newlines.
Open ePub. Double-click chapter. Find a code block. Delete newlines. Repeat. After editing several chapters of Practical Common Lisp this way, I got an idea. Why not write a program to do this for me? The quest had begun.
Allegro CL seemed a likely choice. Sure, I have reservations about a commercial programming language, but Allegro was good enough for both Practical Common Lisp and Casting SPELs in Lisp. Common Lisp is difficult to install, so Lispbox is suggested.
Lispbox
My Internet connection was slow, but steady. I had Lispbox-0.7-with-acl81_express.dmg in no time. Double-click, double-click, drag & drop… done.
Once again, Allegro CL is commercial: free, but not open source. In particular, Allegro CL requires a license file. The Lispbox version of Allegro contains a program called newlicense. When executed, newlicense informs the user that Allegro is too old to warrant a license. Great.
This was too bad, as Lispbox comes with everything a Common Lisper could want: CL, Emacs, SLIME, and ASDF. Lispbox has, apparently, moved to http://common-lisp.net/project/lispbox/. I downloaded Lispbox-0.7-with-ccl-1.5-darwinx86.dmg, which contains a massive 400MB installation, which fails to accept any license file. Oh well, I’ll just have to install Common Lisp, etc. etc. manually.
Installing Common Lisp, etc. etc. Manually
The Allegro CL homepage offers a–surprise!–working edition of Allegro CL v8.2. The edition contains a working license as well as ASDF. Two down, six to go. I also downloaded Aquamacs (did I mention I was on Mac OS X?), which installed and ran equally well.
I don’t know the several hundred shortcut keys for Emacs, so I was eager to install SLIME, a plugin with such helpful features as code highlighting, indentation, compilation, execution, and debugging. Most CL implementations have only a basic interpreter; SLIME adds code completion as well.
Installing SLIME manually is moderately difficult. One must download the files, place them in an appropriate directory, and edit a ~/.emacs configuration file to inform Emacs that SLIME is in fact installed. After much retooling, here is my .emacs:
;; Initialize slime.
(setq inferior-lisp-program "/Applications/AllegroCL/alisp")
(add-to-list 'load-path "/Library/Application Support/Aquamacs Emacs/SLIME")
(require 'slime-autoloads)
(eval-after-load "slime"
'(progn (slime-setup '(slime-fancy))))
;; Automatically use slime mode on .cl and .lisp files.
(add-to-list 'auto-mode-alist '("\\.cl$" . common-lisp-mode))
(add-to-list 'auto-mode-alist '("\\.lisp$" . common-lisp-mode))
;; Start slime.
(slime)
This code is scavenged from several different websites and a trip to Freenode. Lines 1-3 inform Emacs of the locations of a CL installation and a SLIME installation. Line 4 loads the SLIME framework. Lines 5-6 prepare SLIME such that it loads all of its features, including new keyboard shortcuts. Lines 8-10 specify that .CL and .LISP files should automatically open in SLIME mode so that the aforementioned SLIME features are applied to them. Finally, line 12 starts SLIME automatically just like Lispbox’s Emacs does.
That was a chore.
At this point, I had a working and cooperating installation of Allegro CL, Aquamacs, and SLIME. As a result, I was able to read and work through several examples in Practical Common Lisp. I even managed to pre-empt some of Seibel’s code, writing smaller/cleaner code before I saw his. Alas, it was at this point that I must have run (hubris), because everything I did after that was doomed to failure.
Doomed to Failure
Yeah, my code was sleek, but I had a ways to go before I could edit ebooks (remember the intro). ePub files are essentially zipped XHTML documents, ergo I need a Lisp library capable of reading and writing to zip files. As luck would have it, a Common Lisp ZIP library exists. It sports a tidy API and a tidy setup tutorial.
There are two ways to install the ZIP library: automatic and manual. The automatic way requires ASDF-Install. The manual way requires ASDF. Either way, I was destined to become familiar with ASDF and its subsidiaries.
ASDFFFFFFFUUUUUUUU

Had to get that out of the way.
ASDF is nearly impossible to install and use. Fortunately, it comes with Lispbox. Unfortunately, Lispbox is broken. Fortunately, ASDF comes with Allegro CL. Unfortunately, that version of ASDF is crippled–it can’t do any of the commands I see in ASDF tutorials across the web. Fortunately, Allegro successfully loads ASDF. Unfortunately, Allegro fails to load ASDF-Install no matter where I place the files or how I configure ~/.clinit.cl. Fortunately, ASDF comes with SBCL. In fact, the Mad Scientist expressed similar misgivings about ASDF problems and reported that SBCL quickly resolved them.
SBCL
Lost in Technopolis has an excellent tutorial for installing SBCL on Mac OS X. The basic idea is:
- Install MacPorts.
- Use MacPorts to install Emacs, SBCL, and SLIME in one fell swoop.
This all ran so smoothly, I wondered why I had spent so much time and effort on Allegro/Aquamacs. In a few minutes, SBCL finished compiling and was ready for duty. The interpreter was a bit finnicky: the debugger constantly gets in your way, and the command to exit SBCL is hidden deep in some underwater cave. Eventually, (quit) worked.
SBCL does indeed come with ASDF, and indeed SBCL easily installs ASDF-Install, indeed. Very soon indeed, ASDF-Install began installing ZIP, the last remaining sidequest to editing ebooks with Lisp. Very soon indeed, ASDF-Install, or ZIP, or ZIP’s several dependencies failed, and the ZIP install borked with errors such as
Cannot open: file exists
and
gray.lisp.lisp No such file or directory.
No dice. Throughout the day I have posted bug reports on Stack Overflow and two mailing lists. One mailing list was very active, and I soon got an email reply suggesting I drop ASDF for Quicklisp.
Quicklisp, or the End of my Tether
An oasis in the desert of broken software, Quicklisp is. The homepage is simple and elegant. The installation process is as easy as downloading a .LISP file and loading it.
Upon running the tutorial’s commands, I receive the error
==================================================
163,840 bytes in 0.09 seconds (1720.43KB/sec)
; Fetching #
; 2.78KB
==================================================
2,846 bytes in 0.001 seconds (2779.30KB/sec)
debugger invoked on a SB-INT:SIMPLE-FILE-ERROR:
can't create directory /Users/andrew/.cache/common-lisp/sbcl-1.0.44-
darwin-x86-64/Users/andrew/quicklisp/
Meanwhile my roommate has everything working on his Kubuntu setup with apt-get install emacs clisp slime. It’s just not fair.
Candide is Becoming More Relevant by the Second
MacPorts knows SBCL but not CMUCL. It knows CLISP but not GCL. While CLISP installs, I begin manual installation of GCL.
- Download GCL source from five years ago (really).
- Run ./configure.
- ./configure error’s.
- Follow ./configure‘s helpful advice.
- Run ./configure --enable-machine=FreeBSD, the closest thing to an Intel Mac version.
- ./configure error’s.
As a side note, Dr. Edmund Weitz offers yet another Common Lisp bundle, called Starter-Pack. It uses LispWorks, which automatically and forcibly exits after a couple hours. Also, Starter-Pack is Windows-only.
Let’s check up on CLISP.
It Works
Wait, what?
Your Life Is Meaningful Again
Oh, joy! Let’s test this.
$ cd ~/Downloads
clisp
[1]> (load "quicklisp.lisp")
...
[2]> (quicklisp-quickstart:install)
...
==================================================
2,846 bytes in 0.001 seconds (2779.30KB/sec)
Upgrading ASDF package from version 2.004 to version 2.009
; Fetching #
; 0.40KB
==================================================
408 bytes in 0.003 seconds (132.81KB/sec)
==== quicklisp installed ====
[3]> (ql:quickload "zip")
To load "zip":
Load 1 ASDF system:
zip
; Loading "zip"
("zip")
[4]>
Yes, yes, a thousand times yes! Now back to helping Seibel organize his pop music.