Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: a324052551
Fetching contributors…

Cannot retrieve contributors at this time

105 lines (71 sloc) 2.65 kB

Hello Clojure!

These are a series of small projects written while learning Clojure. It assumes some knowledge of Emacs and Lisp, but no experience with Clojure or Java.

  • hello-world
  • use-java
  • basic-io
  • strings
  • functional-data
  • types
  • chat-service

Installing Clojure

Follow these steps to set up Clojure with Emacs integration on OS X:

  • Install Java Developer for Mac OS X (via Apple Developer Portal)

  • Set up package.el and Marmalade

  • Install clojure-mode and paredit

  • Install leinengen

  • lein plugin install swank-clojure 1.3.3

  • lein new hello-world

  • Open hello-world/project.clj in Emacs

  • M-x clojure-jack-in to start SWANK.

Changes to .emacs include:

;; package.el and Marmalade
(require 'package)
(add-to-list
  'package-archives
  '("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)

;; paredit
(autoload 'paredit-mode "paredit"
  "Minor mode for pseudo-structurally editing Lisp code."
  t)

;; clojure-mode
(defun customize-clojure-mode ()
  (paredit-mode 1)
  (local-set-key "M-{" 'paredit-wrap-curly)
  (local-set-key "M-}" 'paredit-close-curly-and-newline)
  (local-set-key "M-[" 'paredit-wrap-square)
  (local-set-key "M-]" 'paredit-close-square-and-newline))

(add-hook 'clojure-mode-hook 'customize-clojure-mode)

Using SLIME

Some clojure-mode keyboard shortcuts:

  • C-x C-e: Evaluate the form at point
  • C-x C-r: Evaluate the selected region
  • C-c C-z: Switch to slime REPL
  • C-c M-p: Change current REPL package

Some SLIME REPL keyboard shortcuts are:

  • C-C M-o: Clear SLIME buffer

Finding Documentation

Some helpful references are:

Q & A

  • What's the difference between java.* and javax.*? The java namespace is "core" and javax are extensions (Stack Overflow).
Jump to Line
Something went wrong with that request. Please try again.