Fork me on GitHub

Hi 👋 I was curious if anybody knows how I can send code from my file to my REPL and have it be evaluated. cider-eval-last-sexp-to-repl is the closest thing I can find but it requires me to move into the repl and hit enter? I asked the question in ClojureVerse also but no real feedback: I'm using Doom emacs.... I think Spacemacs has this functionality and certain Cursive does 🤷


there's a lovely map that does just this. C-c C-j is the prefix for the insert into repl buffer keymap. there you can do C-c C-j d for top level defun, C-c C-j e for last expression


there are three helpful options for you here

(setq cider-invert-insert-eval-p t)
(setq cider-switch-to-repl-on-insert nil)
(setq clojure-toplevel-inside-comment-form t)
these do: 1. eval automatically when you insert things in the repl. the default was to just put them in the repl but not eval 2. don't switch to the repl during this, just eval it and stay where you are 3. helpful, but it is useful for when you are in (comment ...) blocks to not treat the whole comment block as the top level form, but each form inside it as "top level". Kinda a natural helper with this endeavor


(i had the wrong keybinding, updated now to C-c C-j