For Clojure development on the Mac, I use Sam Aaron's excellent "curated emacs experience", Emacs-live. It's a set of customisations to emacs which were put together primarily to turn emacs into a live music performance tool (with Overtone, a Clojure library for making music). However as a side effect of this it looks beautiful, and comes with a neat Clojure configuration. I use it for all my Clojure development work on the Mac.
To get up and running with Clojure emacs-live:
- Install the latest emacs. You can get Mac binaries at http://emacsformacosx.com/
Install emacs-live. Easiest way is to run the "brogrammer" installation script
bash <(curl -fksSL https://raw.github.com/overtone/emacs-live/master/installer/install-emacs-live.sh)
You can also do a manual installation following instructions at the github repo https://github.com/overtone/emacs-live
Install leiningen. Sounds like you have that already. If not, just do
brew install leiningen
(you have homebrew right? If not, you can follow the instructions at the leiningen repo https://github.com/technomancy/leiningen).
Now for your real questions....
How do I easily see and access all of my projects? Emacs has built in bookmarking - I just bookmark the root directory of each project so I can jump to it quickly. To bookmark a file or folder use the key command
C-x r m
, and to see the bookmark list useC-x r l
. You can browse around directories in emacs using a text-based directory browser (calleddired
) which is accessible by the key commandC-x d
.How do I quickly test/modify my projects in a REPL? Emacs-live has nrepl.el included. This means that from any clojure source file you can invoke the command
M-x nrepl-jack-in
. This will give you a repl which you can use to test your program. Any.clj
file loaded in emacs will put you into clojure-mode. Some useful commands in clojure-mode are:C-c M-n
(from source file) switch namespace of repl to namespace of current source fileC-c C-k
evaluate current buffer (file)C-x C-e
evaluate last s-expressionM-.
jump to definitionM-,
jump back
How do I have my windows set up? I usually have a horizontal split (
C-x 2
), with a repl in the lower window and the source file I'm currently working with in the top window. I'll switch between open source files in the top window usingC-x b
(switch buffer). Works for me.How do I package them once they are complete? Use
lein uberjar
from a command line (M-x eshell
) to package up the project and its dependencies.
Note:
I've used the standard shorthand for expressing keyboard shortcuts in emacs above. It's a bit archaic, but on the Mac, as standard, C
is mapped to the control key, and M
is mapped to the alt key.