I am developing a pet project with Clojure, but wonder if I can speed up my workflow a bit.
My current workflow (with Compojure) is:
Not a complete workflow description, just a few ideas:
It is possible to remove a Var from a namespace with the ns-unmap
function. For added convenience, an undef
macro can be built on top of it e.g. like so:
(defmacro undef [& syms]
`(do ~@(map (fn [s] `(ns-unmap *ns* '~s)) syms)))
ns-unalias
may also be of interest.
There's no reason to go through the files holding the namespaces just to do C-c C-k in each of them; you can just require
the namespaces you need at the REPL.
Moreover, if you type a few characters at the SLIME REPL and then use M-p / M-n to browse history, only the entries matching the initial bit of text you entered by hand will be displayed. This is compatible with Paredit (the trailing closing bracket(s) will not be a problem). So, if you build up a huge require at the start -- (require '[foo :as f] '[bar :as b] '[clojure.contrib.sql :as sql] ...)
-- then after restarting Swank, all you need to do is to type something like (require '[f
and press M-p to bring that form to the REPL prompt again.
Admittedly, this could be automated in a number of ways (e.g. having the Swank REPL search for a configuration file, or perhaps a simple macro expanding into an appropriate require
form which could be used after bringing in just one utility namespace from the project -- especially the latter idea would be easy to implement), but I find it sufficiently low on the annoyance factor that I haven't so far bothered with any improvements.
You can use C-c C-z to make a window with the SLIME REPL pop up while you are in a SLIME-enabled buffer. Also, you should try using ido if you haven't already. I tend to work with a code buffer open in a window on the left hand side of the screen and a REPL buffer on the right; with windmove-left
and windmove-right
bound to some convenient keys, I tend to be pretty happy. If I need to look at additional buffers often, I use extra Emacs frames.
Incidentally, I don't use lein swank
normally, I prefer my custom clojure-project function (a tweaked version of Phil Hagelberg's original). On occasion, I feel a desire to improve it... perhaps I'll deal with per-project import
/ require
automation next time that happens. ;-)