Setting Up Emacs for Lisp Hacking in Cygwin

So there you are… hacking away merrily in Emacs with your nice tidy LispBox. But all the while a creeping awareness of the subtle differences of computing cultures take root in your consciousness. Or, more likely, they are shoved in your face every time you try to do anything in Emacs. Unlike, say, Tortoise SVN, Emacs defies conventions of the Windows operating system at every turn. It even makes you feel guilty for using a mouse. It makes you feel guilty for using any application other than Emacs!

But you’re hacking away, mastering recursion and closures… and still you wonder if you’re missing something in your Emacs experience. Would it be an even more powerful tool on its own turf? Are the people raving about the power of Emacs using it along side native Unix tools to perform mindbending feats of development magic? What would happen if you mastered that same Software Toolbox and began concatenating files with cat, reading text streams in chunks with head and tail, sorting files with sort and tsort, filtering files with tr, and removing duplicate lines with uniq? What would happen to your brain if, after opening up a man page, you actually could do something useful with what you found on the screen? Oh heck… you already pledged a lifetime of effort in your quest to understand Lisp macros… why not pledge another one for Emacs and a third for obscure Unix commands.

You install Cygwin on your box. It’s a painless process… and you even check everything Lisp related no matter how buried they are in that strange tree of files. You open Emacs just fine… and it doesn’t appear to know about any of those Lisp programs you pulled down. So you go back to your Cygwin setup and look for slime, but it doesn’t turn up.

So you manually download the slime-2.0.tgz file. You created a folder in your Cygwin directory… and you even manage to “unzip” it:

gzip -dc slime-2.0.tgz | tar -xof –

(Though you’ll never admit to having actually typed “man untar“.)

You pr README in the new slime directory and discover that Emacs need a few lines of code in order to grok Slime’s existence. No problem! You just need to add them to your .emacs file! But… it’s been months since you did that and you can’t remember how to set up a home directory… and its probably a little different in Cygwin anyway– and hey, you don’t always want Slime to do its little song and dance every single time you open up Emacs. So you open up the README file with Emacs, copy the text over to a new file and create the file slime.el:

(add-to-list ‘load-path “/cygdrive/c/cygwin/lispy/slime-2.0/”) ; (the path to where you unzipped slime-2.0.tgz)
(setq inferior-lisp-program “/cygdrive/c/cygwin/bin/clisp.exe”) ; this is where Cygwin puts the clisp program
(require ‘slime)

After saving the file, you just type M-x load-file and give Emacs the file-path to your new file to execute that elisp code… then M-x slime… and suddenly you see that comforting image that brings back such fond childhood memories of Hanukkah and going to the temple. Or something like that.

(If you happen to use Rxvt, you might be shocked by the new color scheme for your REPL screen… and be irritated by the garbage characters that hamper your M-x shell experience. And you wonder if maybe you should be using Cygwin from Emacs instead of the other way around….)

You rise from your swivel chair with a new confidence… and stride from your lair knowing that, in a pinch, you’ll be able to configure Slime with other versions of Emacs and Lisp… and you won’t have to wait for someone to make a new version of LispBox to work with Emacs 22.


6 Responses to “Setting Up Emacs for Lisp Hacking in Cygwin”

  1. chuck Says:

    Basic stuff though it may be, I appreciate your putting out such a nice simple explanation for this. I just now got my emacs/SLIME environment installed on Cygwin myself, after having been limited to only being able to hack Lisp on my Ubuntu partition (and having to reboot is just enough inconvenience to deter one).

    Thought I’d let you in on some things I did differently, in case it’s of interest to anyone:

    * installed Cygwin/X. The Cygwin setup executable now includes all the Cygwin/X stuff, so this is much easier than it used to be!!

    * installed the clisp package that is part of Cygwin. When did they put that in there? Apparently it’s been a while since the last time I installed Cygwin.

    * unpacked slime in my Cygwin home directory

    This way the configuration is purely cygwin — the load-path is ~/slime-2.0/ and the inferior-list is /usr/bin/clisp.exe

  2. nothing happens Says:

    […] a little bit here and there for some time now, especially at work, and after happening across this blog post, I got the idea to try setting up a SLIME environment on my Windows partition. To my very pleasant […]

  3. Roman Says:

    Looks nice, but I have got on my cygwin following at the end of this steps:

    These Swank interfaces are unimplemented:

    ;; Loaded file /home/rtg/lisp/slime-2.0/swank-loader.lisp
    [2]> ;; Swank started at port: 2390.

    Process inferior-lisp segmentation fault (core dumped)

  4. RomanG Says:

    Yes, this way works, but I have to upgrade my cygwin install to the current.

  5. The Path to Enlightenment is Littered With Parentheses « Learning Lisp Says:

    […] of the pain out of it… and setting up Clisp with Emacs has not proven to be that difficult on Cygwin or Linux even for me. My debugging skills are pretty weak though: I generally just hit the number […]

  6. » Blog Archive » Setting Up Emacs for Lisp Hacking in Cygwin Says:

    […] Nice article about how to set up emacs under cygwin for use with Lisp (clisp). […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: