Here is a list of steps that should get you to a working Emacs+Clojure SLIME on Mac OS X. I've also used it on Linux (without the MacPorts command, instead using its package manager to install a working GNU emacs).

If you don't have many MacPorts programs installed, or don't mind reinstalling them, you can "nuke the site from orbit, just to be sure" by removing /opt and everything in it, then do:

    sudo port install em...@+x11

That will take a while. Then start up the X11 server, either the default one that comes with OS X as an optional install, or Xquartz from http://xquartz.macosforge.org

Hopefully /opt/local/bin will be earlier in your PATH than /usr/bin at this point. Installing MacPorts should edit your shell's rc file to do this for you already. You can check with "echo $PATH" or "which emacs". The latter should show /opt/local/bin/emacs if everything is set up to use MacPorts commands in preference over the default OS X versions. If not, use the command:

    PATH=/opt/local/bin:$PATH

preferably in your .bashrc or corresponding init file for the shell you use. Then you can use the command "emacs" to start the MacPorts version (which is GNU Emacs).

Follow the instructions on the ELPA page for installing it:

    http://tromey.com/elpa/install.html

After you do M-x package-list-packages, go down the list of packages until the cursor is on the line for the package "clojure-mode", press the "i" key to mark it for later installation. Do the same for the "slime-repl" package. Then press "x" to execute the installations of those marked packages.

Install Leiningen by following the instructions on its home page. Create a new project with it, like so:

    lein new swank-clj-1.2
    cd swank-clj-1.2

Now edit the file project.clj to look like this:

----------------------------------------
(defproject swank-clj-1.2.0 "1.0.0-SNAPSHOT"
  :description "FIXME: write"
  :dependencies [[org.clojure/clojure "1.2.0"]
                 [org.clojure/clojure-contrib "1.2.0"]]
  :dev-dependencies [[swank-clojure "1.2.1"]])
----------------------------------------

Tweak the version numbers if you want to be closer to the bleeding edge. Then run:

lein deps (this downloads JAR files if needed, and copies them into subdirectory "lib")
    lein swank

You should see this:

    user=> Connection opened on local port  4005
#<ServerSocket ServerSocket[addr=localhost/ 127.0.0.1,port=0,localport=4005]>

From inside of emacs, use the command:

    M-x slime-connect

Press return after that, and you should see prompts asking you for the IP address and port number. The defaults hopefully match the 127.0.0.1 and 4005 in the output of "lein swank", but if not, type in values that do match the ones output from "lein swank".

If you see a message at the bottom of the emacs window like:

Versions differ: nil (slime) vs. 20100404 (swank). Continue? (y or n)

Just press "y" and go on. I don't know exactly why that happens, but it hasn't caused me any problems I've noticed.

An emacs buffer should be created with a Clojure prompt "user>". Type the characters (, then +, then a space, and look at the bottom of the emacs window and you should see the arguments taken by + as:

    ([] [x] [x y] [x y & more])

Or type "(pmap " (ending with a space character), and you should see at the bottom its arguments:

    ([f coll] [f coll & colls])

You should also see similar hints when editing files in Clojure mode, e.g. ones that end in .clj should automatically be in Clojure mode.

Andy



On Dec 9, 2010, at 9:33 PM, javajosh wrote:

On Dec 9, 5:41 pm, Alec Battles <alec.batt...@gmail.com> wrote:
On Dec 6, 9:16 pm, Phil Hagelberg <p...@hagelb.org> wrote:
On Mon, Dec 6, 2010 at 9:00 PM, javajosh <javaj...@gmail.com> wrote:
Sorry for asking here, but I think it's at least a little relevant to Clojure since I for one wouldn't be installing emacs if it wasn't for Clojure and Slime. Getting prompts about what the function arguments are seems like a HUGE benefit when learning this langauge. I imagine
other non-emacs people might have a related question, so I'll give
asking this question a shot.

sudo ports install slime

Swank Clojure (the Clojure adapter for SLIME) depends on a particular version of Slime; the one in Macports is probably not it. I recommend
installing via package.el instead as the swank-clojure readm
suggests:https://github.com/technomancy/swank-clojure#readme

Thanks Phil, I'll give that a shot.

Did that work?

If not, try installing a different emacs.

I don't use OSX, but with the installation process temacs and src
failing to load in the error message and all, I'd try that.

http://www.delorie.com/gnu/docs/elisp-manual-21/elisp_715.html

Alec

The short answer is that I've punted and have been using the
counterclockwise plugin for Eclipse. (http://code.google.com/p/
counterclockwise/) It is more excellent than I have any right to
expect. It does things like highlight the difference between macros
and functions, and that makes me happy.

I would still like to see slime in action, however. I have two emacs
installed, GNU and Aquamacs. macports is still not able to do anything
- I'm actually rather concerned about it's health.

$ emacs --version
GNU Emacs 22.1.1

I don't really know macports (or the native packager, pkgutil I think)
well enough to know what is responsible for installing that emacs.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to