Adding Inferior Lisp Support for clojure-mode
It has been a while since I updated clojure-mode, after the update inferior-lisp stopped working. At first I thought I messed up something because I updated clojure, clojure-contrib, clojure-mode all at the same time (bad move!). After making sure clojure and clojure-contrib works I looked at the clojure-mode's source code and found this commit which removes the subprocess support (inferior-lisp) for clojure-mode and advises to use slime and swank-clojure. Slime is nice but I wanted my inferior-lisp support back.
If you don't have any setup for inferior-lisp support use the following snippet, setting the classpath according to your needs,
(setq class-path (concat "-cp "
"./extLibs/*:"
"../extLibs/*:"
"./classes/:"
"."))
(setq clojure-command (concat "java -server -Dfile.encoding=UTF-8 "
class-path " clojure.lang.Repl" ))
(setq inferior-lisp-program clojure-command)
This will let inferior-lisp to run clojure REPL, to be able to send code from your clojure buffer to inferior-lisp buffer use the following key bindings.
(defun na-load-buffer ()
(interactive)
(point-to-register 5)
(mark-whole-buffer)
(lisp-eval-region (point) (mark) nil)
(jump-to-register 5))
(add-hook 'clojure-mode-hook
'(lambda ()
(define-key clojure-mode-map
"\e\C-x" 'lisp-eval-defun)
(define-key clojure-mode-map
"\C-x\C-e" 'lisp-eval-last-sexp)
(define-key clojure-mode-map
"\C-c\C-e" 'lisp-eval-last-sexp)
(define-key clojure-mode-map
"\C-c\C-r" 'lisp-eval-region)
(define-key clojure-mode-map
"\C-c\C-l" 'na-load-buffer)
(define-key clojure-mode-map
"\C-c\C-z" 'run-lisp)))
From the commit it seems that the only thing that got removed is bunch of key bindings, snippet above pretty much reverses the commit and adds a new function to send the buffer you are working on to REPL and gives you a functional inferior-lisp REPL.