Fork me on GitHub
#spacemacs
<
2018-08-08
>
reefersleep10:08:54

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? 🙂

eggsyntax14:08:15

@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.

Chase16:08:34

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

Chase16:08:50

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
eggsyntax16:08:38

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.

Chase16:08:00

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

eggsyntax16:08:12

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

eggsyntax16:08:23

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

eggsyntax16:08:05

Closing backtick too

eggsyntax16:08:14

It's not lisp 😆

Chase16:08:16

cool, thatnks!

Chase16:08:13

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
eggsyntax16:08:51

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.

Chase16:08:44

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

eggsyntax16:08:21

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

eggsyntax16:08:40

Wait, no, that's custom.

eggsyntax16:08:14

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

Chase16:08:52

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.

eggsyntax16:08:56

I bind it in my .spacemacs:

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

eggsyntax16:08:21

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).

Chase16:08:48

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?

eggsyntax16:08:46

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).

eggsyntax16:08:10

Mine are all at https://github.com/eggsyntax/dotfiles/blob/master/.spacemacs if you're curious (but it's messy as hell, there are lots of easier-to-read ones out there).

Chase16:08:46

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.

eggsyntax16:08:36

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

Chase16:08:20

what does the clojure-lint layer provide you?

eggsyntax16:08:07

Linting on the fly

eggsyntax16:08:27

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

Chase17:08:14

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

eggsyntax17:08:19

Totally! You'll want to read at least this bit to learn how to configure it to avert false positives: https://github.com/candid82/joker#reducing-false-positives

Chase17:08:23

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!

eggsyntax17:08:59

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

eggsyntax17:08:26

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

eggsyntax17:08:41

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?

Chase17:08:39

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.

eggsyntax18:08:32

@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!

Chase18:08:47

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.