Hacker News new | ask | show | jobs
by danneu 4750 days ago
I learned Clojure + Emacs + Evil-mode + nrepl.el at the same time a few months ago and haven't really changed anything about my workflow since then.

This is how I start Emacs:

    * Open emacs
    * `c-x c-f` to navigate to and open my clj file
    * `c-c m-j` to start nrepl session (opens up in a pane split)
    * `c-w h/j/k/l` to move between windows
    * `m-x find-file-in-project` (I mapped to `;a`) to navigate to 
      other clj files in the git project
And this is my workflow once I have source file and nrepl split-panes open:

    * Edit code
    * `c-x c-e` to eval the expression above cursor
    * `c-c c-k` to eval entire source buffer
    * `m-hyphen c-c c-z` to load source file 
      namespace into nrepl window which I rarely do
I actually rarely use the repl window since you can eval code in the source file.

* I pretty much treat my source file as my repl and use `c-x c-e` to execute the previous form. (Screenshot: http://dl.dropbox.com/u/51836583/Screenshots/l0.png)

* Also, I'll often put the code I'm trying to get to work like `(my-func 1 2 3)` at the bottom of my source file. Then, while I'm hacking on `my-func`'s implementation, I mash `c-c c-k` (eval buffer) which returns the result of the last expression in the file.

* Another nice way to utilize `c-c c-k` is to put your `(assert (= (my-func 1 2 3) 42))` tests right into the source file. The tests will get run every time you eval the buffer. It's a solid test-driven loop baked into the core library!

(See more nrepl keymappings here: https://github.com/kingtim/nrepl.el#keyboard-shortcuts)

2 comments

I wish I could upvote you more. I've been playing with clojure for weeks and I use nrepl, but it never clicked what a solid workflow could be.
This deserves more upvotes than the 1 that I can give it.