Gangmax Blog

自由之思想,独立之精神

Clojure Development Setup

| Comments

  1. Leiningen

    Download the lein script and set it to be executable (chmod a+x ~/bin/lein), then add it in your “$PATH” environment variable. Run it to install lein with clojure.

  2. emacs24

    Refer here:

1
2
3
4
5
6
7
# My OS is Ubuntu 12.04(Precise)
sudo apt-get purge emacs-snapshot-common emacs-snapshot-bin-common emacs-snapshot emacs-snapshot-el emacs-snapshot-gtk emacs23 emacs23-bin-common emacs23-common emacs23-el emacs23-nox emacs23-lucid auctex emacs24 emacs24-bin-common emacs24-common # Remove any existing emacs.
sudo add-apt-repository ppa:cassou/emacs # Add PPA repository.
sudo apt-get update # Update APT sources.
sudo apt-get install emacs24 emacs24-el emacs24-common-non-dfsg m17n-docs # Install emacs24.
# OR:
sudo apt-get install emacs-snapshot-el emacs-snapshot-gtk emacs-snapshot # On my Ubuntu 10.04(Lucid) environment, the above command didn't work, so I used this one instead.
  1. clojure-mode

    1. Add the following code in your “~/.emacs.d/init.el” file:
1
2
3
(require 'package)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)
2. Open emacs24 and run the following command:
1
2
3
M-x eval-buffer
M-x package-refresh-contents
M-x package-install [RET] clojure-mode [RET]
  1. Start NRepl in emacs

    1. Make sure you have the following content in your “~/.emacs.d/init.el” file:
1
2
3
4
5
6
7
8
9
(require 'package)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)
(when (not package-archive-contents)
    (package-refresh-contents))
(defvar my-packages '(clojure-mode nrepl))
(dolist (p my-packages)
    (when (not (package-installed-p p))
        (package-install p)))
2. Start emacs and run the following command:
1
M-x nrepl-jack-in
3. Create a new project with "lein new test" and open the "core.clj" file by emacs, then put your cursor at the end of the new function "foo" and do:
1
C-x C-e
4. Move your focus to the REPL window and run:
1
(foo "bar")
5. Then you can see the result of this function call.

emacs_screen_copy

Comments