Fork me on GitHub

I’d like to have RET insert a newline in the CIDER repl and C-<return> evaluate the sexp. I’ve tried entering the following into my dotspacemacs/user-config:

;; make cider repl indent and newline on enter and eval on
  ;; control-enter
  (define-key cider-repl-mode-map (kbd "RET") #'cider-repl-newline-and-indent)
  (define-key cider-repl-mode-map (kbd "C-<return>") #'cider-repl-return)
, and this makes the RET behaviour correct, but I cannot trigger C-<return> with my control key and enter key. Through other means, I can trigger it, if I do SPC : (named M-x) and then search for cider-repl-return. Anyone know how to fix this? 🙂


@reefersleep dunno if there's something special about binding C-RET, but you might use SPC h d k to see what it's bound to, both before and after the attempt to bind it.


C-RET is awesome! It closes all your ending parens before evaluation.


I know that probably doesn't help but i've been loving it. to go to a new line i've just been deleting the last closing parens real quick before I hit RET. And then when I'm done with the multiline input I use the C-RET to get it all closed up nicely.

metal 4

I've never really done it that way; I should try it. I usually just write my multiline stuff in whatever regular clj/s buffer I have handy, and then send it over to the REPL with , s e.


quick slack newb question. how did you make the , s e look like a code snippet?


Heh, oh good, that worked, I thought it might screw it up. `


Or triple-backtick
for multiline
different format as you can see


Closing backtick too


It's not lisp 😆


cool, thatnks!


Yeah, i think as i get more experienced I'll go that route. Right now, repl first tinkering seems more natural for me because I'm getting tons of errors and using the (doc f) capability a lot! Plus the tutorials are half throwaway examples that I alter in various ways just to see what will happen so I find it easier to just stay in the repl for those. when i start building a real program i'll go the other way. I didn't know , can sub in for SPC-m though. One keystroke saved!

👍 4

Yeah, or you can set it to some other key if you prefer, it's dotspacemacs-major-mode-leader-key. Yeah, I mean I write throwaway REPL code in whatever buffer is handy...I don't keep it there typically. I'm only using it as an easy way to write and edit multiline expressions.


cool. and then you just delete it from your program file? or do you have multiple buffers hooked into the same repl session?


Er...both. May not quite be understanding the question properly 🙂 There's also , c s to get a scratch clojure-formatted buffer.


Wait, no, that's custom.


It's cider-scratch; I'm not sure if it's bound to anything by default.


ok. yeah i'm probably not explaining. basically i create a new project using lein like lein new app brave-book and I just do all the exercises in the core.clj file hooked into a repl. so it's probably not a emulation of how it is working in a real project.


I bind it in my .spacemacs:

(with-eval-after-load 'clojure-mode
    (define-key evil-normal-state-map (kbd ", c s") 'cider-scratch)


Oh, yeah, in that case I'd likely just type it in the core.clj and then delete after sending to REPL (or else do a repeated edit-send cycle until I get to a version I'm happy with, and then leave it in core.clj, if it's something I actually want to keep).


i gotcha. this cider-scratch thing is neat. that could be handy for random tinkering. when people say they add something to their .spacemacs does that mean you put that function within the dotspacemacs/user-config function?


Yep, correct. Along with a bunch of other clj-specific bindings (you can put all of them within the same (with-eval-after-load 'clojure-mode ...), no need to repeat that).


Mine are all at if you're curious (but it's messy as hell, there are lots of easier-to-read ones out there).


nice. I'll bookmark it. I'm trying to learn "default Spacemacs" (which is probably considered absurd considering it's a heavily customized emacs already) before I change things too much.


Totally. In the long run you'll probably want a bunch of custom keybindings, that actually seems to be the most common case 😉


what does the clojure-lint layer provide you?


Linting on the fly


(ie catching & displaying basic errors without having to run the code)


ok, cool, i'm going to try that. i imagine that could be helpful for a learner too


Totally! You'll want to read at least this bit to learn how to configure it to avert false positives:


cool. i'm tabling it for now but i will look into it soon. I have to figure out how to install joker and a couple other tweaks it seems. This is the rabbit hole that keeps me from doing actual clojure programming. hahaha. i knew opening up slack was a risk!


Oh, that's right, you've gotta install joker separately, I forgot about that.


Yeah, I lose WAY too much time tweaking my toolchain 😜


Hmm, glancing back, I'm not sure there's any good reason to have both clojure-lint and syntax-checking, I'll have to look into that. Anyone else know offhand?


i do know that after adding clojure-lint and then commenting it out my spacemacs was all out of wack! lol. I had no syntax highlighting and all kinds of fun weirdness. I had to re-add a few packages to get back to normal. Thanks eggsyntax! Lol. I kid, I kid.


@chase-lambert OK, looking back at discussion on my work slack, I actually meant the syntax-checking layer. I'm not sure why clojure-lint is in there, I'll try pulling it out when I get a chance. If you turn it on, then a) have to have joker on your path, and b) have to restart spacemacs. Sorry for misleading!


no worries! it's really my own damn fault for immediately installing something after 10 seconds of thought and foresight. a lesson i've learned too many times. people would be appalled at the amount of full powerwashes I do of my chromebook just cuz I'm ocd about one thing not working right and wanting everything fresh.