LispWorks Personal under SLIME on OS X

A while ago, Bill Clementson wrote about how to make Lispworks Personal Edition work under SLIME. It’s a lot harder than you might think (well, harder than I thought, anyway). And it seems like they change things over time to make it even more difficult. So, Bill’s 18-month-old instructions no longer work. I did a lot of cursing while trying to fix it. Here’s what I came up with. (Again, this is mostly Bill’s work, I just changed what was necessary to have it work with LispWorks 4.4.6.)

LispWorks Personal won’t load init files, so you have to trick it into setting up SWANK. Bill put the following in ~/.slime.lisp:

sh: /home/pfeilgm/bin/enscript: No such file or directory

Create an AppleScript application (save with file format “application” in Script Editor) called “lw-start.app” with the following content:

tell application "LispWorks Personal"
    activate
end tell

tell application "System Events"
    tell process "lispworks-personal-4-4-6-darwin"
        repeat until get frontmost
        end repeat
        if exists window "LispWorks Personal Edition" then
            tell window "LispWorks Personal Edition"
                tell button "Close"
                    click
                end tell
            end tell
        end if
        tell window "Listener 1"
            keystroke "(load \"~/.slime.lisp\")"
            keystroke return
        end tell
    end tell
end tell

tell application "Finder"
    set visible of every process whose frontmost is true to false
end tell

delay 2

tell application "Emacs"
    activate
end tell

tell application "System Events"
    tell process "Emacs"
        tell window 1
            key code 53
            keystroke "x"
            keystroke "slime-connect"
            keystroke return
            keystroke return
            keystroke return
            (* aborts the fake connection and closes the unused inferior-lisp
               buffer. Remove everything after this point if you don't execute
               this script via M-x slime *)
            key code 53
            keystroke "x"
            keystroke "slime-abort-connection"
            keystroke return
            keystroke "x" using control down
            keystroke "k"
            keystroke return
        end tell
    end tell
end tell

This starts LispWorks, closes its stupid “please buy this” window, tells it to load the swank stuff, hides it, then tells emacs to connect to it. That’s most of the magic.

Getting emacs to call it is pretty simple. Depending on your own style, you may want to create an interactive function like Bill does, but I like to start all my lisps with

1
M-- M-x slime RET <lisp> RET

, so I have the following in my .emacs:

sh: /home/pfeilgm/bin/enscript: No such file or directory

Comments are closed.