MM""""""""`M                                           M""MMMMMMMM M""M M""MMMMM""M MM""""""""`M
 MM  mmmmmmmM                                           M  MMMMMMMM M  M M  MMMMM  M MM  mmmmmmmM
 M`      MMMM 88d8b.d8b. .d8888b. .d8888b. .d8888b.     M  MMMMMMMM M  M M  MMMMP  M M`      MMMM
 MM  MMMMMMMM 88''88'`88 88'  `88 88'  `"" Y8ooooo.     M  MMMMMMMM M  M M  MMMM' .M MM  MMMMMMMM
 MM  MMMMMMMM 88  88  88 88.  .88 88.  ...       88     M  MMMMMMMM M  M M  MMP' .MM MM  MMMMMMMM
 MM        .M dP  dP  dP `88888P8 '88888P' '88888P'     M         M M  M M     .dMMM MM        .M
 MMMMMMMMMMMM                                           MMMMMMMMMMM MMMM MMMMMMMMMMM MMMMMMMMMMMM

So, you have connected Emacs Live to a Clojure process and are now sitting in front of a fresh *nrepl* buffer. Wonderful. Let us begin…

Basic REPL interaction

The *cider-repl* buffer is essentially equivalent to the REPL-y REPL that Leiningen delivers by default when you run lein repl, only you have all the usual advantages that Emacs Live provides you in addition to the power of paredit.

You should see the following at the top of your *cider-repl* buffer:

user>

It’s doing two things. Firstly, it’s telling you that your current namespace (i.e. *ns*) is user and secondly, it’s waiting for you to give it a standard Clojure form to evaluate in the context of that namespace. For example you could type:

user> (+ 1 2)

and then hit RET. and you should see the following

user> (+ 1 2)
3
user>

It prints out the result of evaluating the form, and then gives you another user> prompt and patiently waits for your next move.

REPL history

If you wish to access previous REPL lines you have two options. Firstly you can use the functions cider-repl-previous-input (M-p) and cider-repl-next-input (M-n) to cycle through the history. Once you have found the line you’re looking for, you can then simply press RET to evaluate it again, or you have the option of editing it before evaluation.

Another option is to treat the *cider-repl* buffer like a normal Emacs buffer and simply use the search commands isearch-backward (C-r) and isearch-forward (C-s) to search back and forth through the buffer. When the point is on the line you’d like to re-use, simply press RET and the form will be placed at the prompt ready for a subsequent RET to evaluate it or for it to be edited.

Of course, you’re also free to use standard killing and yanking to manipulate the text.

REPL Output

Output generated by evaluating forms on the *cider-repl* REPL typically gets printed inline back in the *cider-repl* buffer itself.

For example, if you evaluate the following by hitting RET:

user> (println "foo")

You’ll see the following output:

user> (println "foo")
foo
nil
user>

Note that the output from the println - foo is interleaved with the REPL output - nil.

-UUU:@----F2  clojure-repl-interaction.md   All (14,54)    (Markdown Undo-Tree yas VHl AC -1-) --------------------------------------------------------------------