Skip to content

Commit 0f28b61

Browse files
committed
Added clojure-install command and clojure-slime-config function.
Set clojure-src-root to the directory that contains your clojure-related checkouts, then call clojure-slime-config to set up slime. If you don't have clojure, contrib, slime, and swank-clojure installed, use the clojure-install command to get them.
1 parent 019c486 commit 0f28b61

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

clojure-mode.el

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,72 @@ check for contextual indenting."
530530
; (put 'lazy-cat 'clojure-indent-function 1)
531531
; (put 'lazy-cons 'clojure-indent-function 1)
532532

533+
(defvar clojure-src-root "~/src"
534+
"Directory that contains checkouts for Clojure and other libs.
535+
536+
clojure-contrib, slime, and swank-clojure should be here too. Use
537+
the `clojure-install' command to check these out and configure
538+
them for you.")
539+
540+
(defun clojure-slime-config ()
541+
"Load Clojure SLIME support out of the `clojure-src-root' directory.
542+
543+
Since there's no single conventional place to keep Clojure, this
544+
is bundled up as a function so that you can call it after you've set
545+
`clojure-src-root' in your personal config."
546+
547+
(add-to-list 'load-path (concat clojure-src-root "/slime"))
548+
(add-to-list 'load-path (concat clojure-src-root "/slime/contrib"))
549+
(add-to-list 'load-path (concat clojure-src-root "/swank-clojure"))
550+
551+
(require 'slime-autoloads)
552+
(require 'swank-clojure-autoload)
553+
554+
(eval-after-load 'slime '(slime-setup '(slime-fancy)))
555+
556+
(setq swank-clojure-jar-path (concat clojure-src-root "/clojure/clojure.jar")
557+
swank-clojure-extra-classpaths
558+
(list (concat clojure-src-root "/clojure-contrib/clojure-contrib.jar"))))
559+
560+
(defun clojure-install (src-root)
561+
"Perform the initial Clojure install along with Emacs support libs.
562+
563+
This requires git, a JVM, ant, and an active Internet connection."
564+
(interactive (list
565+
(read-from-minibuffer (concat "Install Clojure in (default: "
566+
clojure-src-root "): ")
567+
nil nil nil nil clojure-src-root)))
568+
(mkdir src-root t)
569+
570+
(if (file-exists-p (concat src-root "/clojure"))
571+
(error "Clojure is already installed at %s/clojure" src-root))
572+
573+
(cd src-root)
574+
(message "Checking out source... this will take a while...")
575+
(dolist (cmd '("git clone git://github.com/kevinoneill/clojure.git"
576+
"git clone git://github.com/kevinoneill/clojure-contrib.git"
577+
"git clone git://github.com/jochu/swank-clojure.git"
578+
"git clone git://git.boinkor.net/slime.git"))
579+
(unless (= 0 (shell-command cmd))
580+
(error "Clojure installation step failed: %s" cmd)))
581+
582+
(message "Compiling...")
583+
(cd (concat clojure-src-root "/clojure"))
584+
(unless (= 0 (shell-command "ant")) (error "Couldn't compile Clojure."))
585+
(cd (concat clojure-src-root "/clojure-contrib"))
586+
(unless (= 0 (shell-command "ant")) (error "Couldn't compile Clojure contrib."))
587+
588+
(unless (equal src-root clojure-src-root)
589+
(with-output-to-temp-buffer "clojure-install-note"
590+
(princ (format "You've installed clojure in a non-default location. If you want to use this installation in the future, you will need to add the following line to your personal Emacs config somewhere:
591+
592+
\(setq clojure-src-root \"%s\"\)" src-root)))
593+
(setq clojure-src-root src-root))
594+
595+
(clojure-slime-config)
596+
597+
(message "Installed Clojure successfully. Press M-x slime to continue."))
598+
533599
;;;###autoload
534600
(add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode))
535601

0 commit comments

Comments
 (0)