Fork me on GitHub
#cider
<
2017-01-07
>
dorianc.b01:01:44

ok after much searching I finally figured out the pretty printing thing

dorianc.b01:01:02

Does anyone know how to rebind the cider repl so using the arrow keys will scroll through the history. I tried doing

(define-key 'cider-repl-mode-map (kbd "<up>") 'cider-repl-previous-input)
(define-key 'cider-repl-mode-map (kbd "<down>") ‘cider-repl-next-input))
However I keep getting this error Error in dotspacemacs/user-config: Wrong type argument: keymapp, cider-repl-mode-map

practicalli-johnny01:01:03

@dorianc.b I'd suggest putting (setq cider-pprint-fn “fipp”) under dotspacemacs/user-config in ~/.spacemacs. This should avoid the posibility of the cider package over-riding this setting. The configuration file ~/.spacemacs is equivalent to ~/.emacs.d/init.el. Alternatively, you can also use .spacemacs.d/init.el assuming you do not use ~/.spacemacs, but this is typically only used if you have other local configuration files (and you want to version control them)

practicalli-johnny02:01:36

@dorianc.b for the keybindings I suggest using a hook, as I believe the cider-repl-mode-map is only available once you run the repl. So a hook will pull in the config when cider-repl-mode is activated. So you would use something like

(add-hook 'cider-repl-mode-hook
            '(lambda ()
               (define-key cider-repl-mode-map (kbd "<up>") 'cider-repl-previous-input)
               (define-key cider-repl-mode-map (kbd "<down>") 'cider-repl-next-input)))

dorianc.b02:01:29

@jr0cket Thank you so much. Also your blog posts were really helpful in setting up spacemacs

stanislav07:01:52

Hi everyone. I'd like to setup Emacs to be able to run Clojure repl, but I'm having an issue, and cannot figure it out, since I'm new to Emacs as well. 😐

stanislav07:01:03

When I create a new project with Leiningen, and open the core.clj file in Emacs, when I try to run cider-jack-in, I'm getting the message "Symbol's function definition is void: nil"

stanislav07:01:25

I have the Emacs version 24.5.1, Leiningen 2.7.1, Cider 0.15.0snapshot (20170104.1330)

stanislav07:01:32

Not sure if anything else is relevant for the issue

stanislav07:01:04

I have also asked a question on Stackoverflow, where more details can be found: http://stackoverflow.com/questions/41508593/running-cider-jack-in-in-emacs

stanislav07:01:16

Any help is highly appreciated! 🙂

benedek09:01:51

try to update (remove and reinstall) clojure mode

stanislav14:01:36

Unfortunately, that didn't help (I removed clojure-mode manually from elpa folder, and then did package-install in emacs)...

dpsutton15:01:42

@stanislav can you check cider-client.el for me at line 102?

dpsutton15:01:14

you can just navigate to the function cider-repl-buffers and see if it looks like this

stanislav15:01:24

give me just a second

dpsutton15:01:31

it should look like this

(defun cider-repl-buffers ()
      "Return the list of REPL buffers."
      (seq-filter
       (lambda (buffer)
         (with-current-buffer buffer (derived-mode-p 'cider-repl-mode)))
       (buffer-list)))

stanislav15:01:05

it looks exactly the same

dpsutton15:01:04

let me think

dpsutton15:01:19

ah, do you see any .elc files in there?

dpsutton15:01:17

and we can confirm that this function is the problem

dpsutton15:01:36

can you evaluate (cider-repl-buffers) from somewhere?

dpsutton15:01:12

let's see if that's what's throwing the error

stanislav15:01:14

For each .el file I see the matching .elc.

dpsutton15:01:23

we'll come back to that

dpsutton15:01:33

do you know how to evaluate lisp code?

dpsutton15:01:42

like from the minibuffer or maybe in the scratch buffer?

stanislav15:01:51

not really 😞

dpsutton15:01:55

i have no idea of your level of comfort in emacs so i don't want to talk over your level

dpsutton15:01:10

hit M-Shift ;

stanislav15:01:12

I started looking into Emacs yesterday

dpsutton15:01:30

you'll see in the bottom left eval:

stanislav15:01:36

Could you give me just a second to switch from spacemacs to Emacs?

dpsutton15:01:37

and its asking you to enter code

dpsutton15:01:52

that might not be necessary

dpsutton15:01:00

you could just go to the scratch buffer

dpsutton15:01:09

does spacemacs popup a scratch buffer?

dpsutton15:01:37

type (cider-repl-buffers)

dpsutton15:01:44

and we want to figure out how to eval it

dpsutton15:01:51

i'm not sure what spacemacs keybinding that is

dpsutton15:01:15

we want eval-last-sexp

stanislav15:01:25

I can try the regular emacs binding for clojure?

dpsutton15:01:40

i'm not sure what you mean

dpsutton15:01:58

oh question for you

stanislav15:01:03

Would that be in emacs something like C-x C-e?

dpsutton15:01:11

yeah that is the keybinding in plain emacs

dpsutton15:01:23

did you install cider as a spacemacs layer or as an emacs package

dpsutton15:01:33

i know spacemacs has a different style of loading packages

dpsutton15:01:37

not super sure about that

stanislav15:01:47

It was installed with clojure layer in spacemacs, if I got that right

dpsutton15:01:49

ah i think help is on the way 🙂

dpsutton15:01:07

just making sure we were doing things the way spacemacs likes

dpsutton15:01:12

did you eval that code?

dpsutton15:01:34

have you got it typed in the scratch buffer?

stanislav15:01:43

yes, but I don't know how to evaluate

stanislav15:01:59

the regular C-x C-e does not work, or I am doing it wrong

dpsutton15:01:59

ok, do you know the equivalent of M-x in spacemacs?

stanislav15:01:02

Let me try again

dpsutton15:01:18

it might just be space, i'm not sure

practicalli-johnny15:01:34

M-x in spacemacs is M-x

dpsutton15:01:45

ah thanks jr0cket

dpsutton15:01:56

wasn't sure if it was hooked up to the space key

dpsutton15:01:13

stanislav, hit M-x and then type eval-last-sexp

dpsutton15:01:38

when your cursor is at the end parens of (cider-repl-buffers)

practicalli-johnny15:01:22

spacemacs also has SPC SPC if you are in vim normal mode for M-x.

stanislav15:01:25

I see the binding is the same, but I don't see the result

stanislav15:01:46

nor an error message.

practicalli-johnny15:01:59

we had a working spacemacs & clojure setup, just didnt figure out the brave clojure version of the emacs setup

stanislav15:01:51

Yes, we worked around it 🙂

stanislav15:01:17

I'd still like to figure out why it didn't work with the brave clojure version, specially if it is a bug somewhere.

dpsutton15:01:43

so are you trying to configure emacs with CIDER and spacemacs with clojure layer at the same time?

dpsutton15:01:05

sounds like a lot of toes that get stepped on

dpsutton15:01:13

emacs lisp has no namespaces

stanislav15:01:46

I understand what you just wrote, but not on a very high level, or to rephrase, not sure how that affects me.

stanislav15:01:02

(the last sentence)

dpsutton15:01:53

it basically means if two different packages name things the same, only the last wins

stanislav15:01:10

Thank you for the clarification.

dpsutton15:01:19

so if spacemacs layer and CIDER were fighting to name functions the same thing, we could easily have some really confusing situations

dpsutton15:01:22

but that's not the case

stanislav15:01:49

no, I have replaced all configuration I had in emacs with spacesmacs, and it was working fine

stanislav15:01:04

but the original setup was not, no matter what I tried

dpsutton15:01:07

you can see this all over because functions are named cider--my-private-function. The "namespace" is in the name

dpsutton15:01:23

what do you mean the original setup

dpsutton15:01:32

like when you were running just emacs before spacemacs?

dpsutton15:01:47

but in spacemacs you get CIDER working just fine?

dpsutton15:01:56

how do you switch between the two?

stanislav15:01:15

I removed everything from ~/.emacs.d

stanislav15:01:32

and cloned git repo as suggested on spacemacs website

dpsutton15:01:52

so that explains why no error message right now

dpsutton15:01:00

you don't expect any errors right now, correct?

practicalli-johnny15:01:10

swiching between two ~/.emacs.d directories

dpsutton15:01:10

you have a working spacemacs/CIDER/clojure environment

stanislav15:01:22

but the cider version is the same in both

dpsutton15:01:34

want to switch back into plain 'ol emacs and we'll keep diagnosing?

stanislav15:01:02

sure (that's what I offered to do at the begining of our talk, but you said it might not be necessary 🙂 )

practicalli-johnny15:01:03

my thought is there is a bug in the brave clojure configuration, or more likely something outdated

dpsutton15:01:25

^ that's quite possible

stanislav15:01:29

I updated everything that was possible

dpsutton15:01:33

can you send me a link to the brave clojure stuff?

dpsutton15:01:49

repo/ code whatever?

dpsutton15:01:55

my copy of the book is in the office

dpsutton15:01:08

(great book by the way and he's here on slack)

stanislav15:01:45

So far it's really readable and easy to follow (except for the part that I couldn't get REPL running in emacs 😄 )

dpsutton15:01:14

there's why its not gonna work

dpsutton15:01:23

they are using CIDER 0.8.1

stanislav15:01:04

but I updated cider to the latest version

stanislav15:01:18

I updated all the packages through Emacs

dpsutton15:01:50

did you create the lein profiles file like they say?

dpsutton15:01:13

can you post what's in there?

dpsutton15:01:33

because we definitely don't want the nrepl 8.1 dependency

dpsutton15:01:36

that's super old

dpsutton15:01:47

CIDER manages its own dependencies now

stanislav15:01:57

I updated the dependency there

stanislav15:01:08

and also tried 0.15.0

dpsutton15:01:08

remove that line totally

stanislav15:01:16

also removed the profiles.clj completelly

stanislav15:01:21

but non of that helped

stanislav15:01:34

I have now the emacs from brave clojure configured

dpsutton15:01:51

you're running that version

dpsutton15:01:02

you mean you've booted up emacs not spacemacs?

dpsutton15:01:15

are you in the scratch buffer?

stanislav15:01:19

I apologize if I don't use the terminology correctly

dpsutton15:01:24

no problem at all

stanislav15:01:27

yes, I already tried to eval the previous line

stanislav15:01:33

it detects an error

dpsutton15:01:35

there's no real correct terminiology, just making sure i understand where you are

dpsutton15:01:45

we're gonna debug some emacs lisp

dpsutton15:01:59

and here's how we're gonna do it

stanislav15:01:01

I already have it stop on error

dpsutton15:01:09

easy way to navigate to functions:

dpsutton15:01:22

emacs is self documenting

dpsutton15:01:27

that navigates to functions

dpsutton15:01:47

and we want to navigate to cider-repl-buffers

stanislav15:01:36

When I navigate to the function, I get

stanislav15:01:37

cider-repl-buffers is an alias for `cider-repl-buffers', which is not defined. Please make a bug report.

dpsutton15:01:11

ok i think i might have a hypothesis

dpsutton15:01:27

delete your

dpsutton15:01:40

we want to delete all of the elc files

dpsutton15:01:18

so emacs lisp files (.el) get compiled to (.elc) files

stanislav15:01:31

should I first close Emacs?

dpsutton15:01:45

we're gonna delete them all and let emacs recompile them

stanislav15:01:01

Start Emacs again?

dpsutton15:01:33

and use C-h F to go back to that function

dpsutton15:01:36

and let's see what happens

stanislav15:01:00

Now it does not find it at all

dpsutton15:01:25

can you navigate to the folder that has CIDER in it

stanislav15:01:32

yes, I'm there already

dpsutton15:01:40

is it in ~/.emacs.d/elpa or something similar

dpsutton15:01:55

can you go to the cider-client.el file?

stanislav15:01:06

open it with any editor?

stanislav16:01:22

ok, I have it open.

dpsutton16:01:26

and go to line 102

dpsutton16:01:43

and it'll ask you what line you want

stanislav16:01:49

ok, I'm there

dpsutton16:01:10

are you in cider-repl-buffers ?

dpsutton16:01:29

we're gonna eval that code

stanislav16:01:22

Isn't it C-x C-e?

dpsutton16:01:33

if you're at the end that's eval-previous-sexp

stanislav16:01:40

or that's different?

dpsutton16:01:40

M-C-x is eval this form

stanislav16:01:50

It's like vi, but more complex

dpsutton16:01:00

yeah, easier cause you just do it from anywhere inside the top level form

dpsutton16:01:07

instead of at the closing parens

stanislav16:01:13

So, my cursor should be anywhere inside this function, and I should hit M-C-x, right?

stanislav16:01:33

That doesn't do anything visible

dpsutton16:01:38

that's right

dpsutton16:01:45

you're just defining a function, not invoking it

dpsutton16:01:58

but now we can eval (cider-repl-buffers) and see if it works

stanislav16:01:10

ok, so do it again in scratch?

dpsutton16:01:14

yeah try that

dpsutton16:01:20

we're probably gonna get an error though

dpsutton16:01:27

and i think its because cider isn't loaded at all

stanislav16:01:36

I got an error

dpsutton16:01:40

what did it say?

stanislav16:01:44

the same as I reported initially

stanislav16:01:03

cider-repl-buffers: Symbol's function definition is void: seq-filter

dpsutton16:01:29

ah that's better

dpsutton16:01:41

ok, go back into the cider-client.el buffer

dpsutton16:01:59

and do M-x eval-buffer

dpsutton16:01:03

we are missing a dependency

dpsutton16:01:16

you can see at the top of the buffer is a line (require 'seq)

dpsutton16:01:29

which gives us those seq functions like seq-filter

stanislav16:01:42

is that why I get

stanislav16:01:43

val-buffer: Symbol's function definition is void: Defun

stanislav16:01:46

eval-buffer: Symbol's function definition is void: Defun

stanislav16:01:57

or I accidentally changed something

dpsutton16:01:04

is the capital D what it is saying?

dpsutton16:01:10

it sounds like you've changed something

dpsutton16:01:17

go to the buffer

dpsutton16:01:32

we need to find Defun not defun

dpsutton16:01:39

we might have some typos in there

stanislav16:01:53

Can I do case sensitive search?

dpsutton16:01:09

if you put a capital letter it should do case sensitive

stanislav16:01:21

ok, found one

dpsutton16:01:25

ah where at

dpsutton16:01:30

which function?

stanislav16:01:43

just below the cider-repl-buffers

dpsutton16:01:52

let's replace it with defun

dpsutton16:01:00

correct that typo and re-eval the buffer

dpsutton16:01:37

buffer's re-eval'd?

stanislav16:01:43

it doesn't say anything

dpsutton16:01:46

that's fine

stanislav16:01:49

but I ran the eval-buffer

dpsutton16:01:58

now let's eval an expression

dpsutton16:01:19

that should bring up a line at the bottom of the window letting us eval some code

stanislav16:01:27

yes, I see it

dpsutton16:01:34

(cider-repl-buffers)

dpsutton16:01:39

let's see what it says now

stanislav16:01:01

seq-filter: Symbol's function definition is void: Lambda

dpsutton16:01:09

is Lambda capitalized?

dpsutton16:01:18

there's our error

dpsutton16:01:24

let's make that lowercase

dpsutton16:01:29

and eval the buffer again

dpsutton16:01:37

but it sounds like we've got some untrustworthy code

stanislav16:01:04

I'm pretty sure I didn't change those two accidentally

dpsutton16:01:09

its really weird

dpsutton16:01:19

i wonder if some kind of spell check mode ran in these buffers

stanislav16:01:19

and I for sure didn't hit any saves

dpsutton16:01:41

did you fix that typo?

dpsutton16:01:56

re-eval the buffer

dpsutton16:01:15

and let's re-eval the expression

dpsutton16:01:27

M-: (cider-repl-buffers)

stanislav16:01:04

Now I get the same error from the start 😐

stanislav16:01:05

Symbol's function definition is void: nil

dpsutton16:01:17

now we're gonna debug some emacs lisp

dpsutton16:01:27

go back to cider-repl-buffers

dpsutton16:01:34

where its defined

dpsutton16:01:54

and hit C-u M-C-x

dpsutton16:01:05

the same thing that eval'd it the first time

dpsutton16:01:08

but with a prefix

dpsutton16:01:43

prefix is emacs slang for C-u

stanislav16:01:44

Ok, I ran it

stanislav16:01:59

cool, thanks for adding some explanations along the way!

dpsutton16:01:07

you should have seen a message at the bottom like "edebug instrumented cider-repl-buffers

dpsutton16:01:17

we just told emacs we want to debug this function call

stanislav16:01:31

I missed that message

dpsutton16:01:43

it should have worked

stanislav16:01:51

I see a light blue ^L

dpsutton16:01:05

hmm, it may not have worked

dpsutton16:01:08

i think those are page breaks

stanislav16:01:28

ok, I will try one more time

stanislav16:01:04

Ok, I saw it now

stanislav16:01:09

but it's not instrumented

stanislav16:01:18

it's only "edebug cider-repl-buffers"

dpsutton16:01:27

yeah that's what we want

dpsutton16:01:29

its instrumented

dpsutton16:01:36

eval (cider-repl-buffers)

dpsutton16:01:41

and it should let you step through

dpsutton16:01:45

it'll go to each form

dpsutton16:01:49

you can hit n for next

dpsutton16:01:54

c for continue

stanislav16:01:34

It does not step into the function

stanislav16:01:46

or does not stop on breakpoint, but shows the message before that one

dpsutton16:01:55

the error message?

stanislav16:01:59

(I guess before it gets to the breakpoint)

dpsutton16:01:06

let's go nuclear

dpsutton16:01:10

let's delete cider

stanislav16:01:28

just to make sure I understand

dpsutton16:01:33

delete the whole directory

stanislav16:01:34

I should delete it from elpa dir

dpsutton16:01:42

and then restart emacs

dpsutton16:01:46

let's clear out all the junk

dpsutton16:01:28

open up emacs again

dpsutton16:01:34

and hit M-x package-install

dpsutton16:01:53

or actually M-x list-packages

dpsutton16:01:00

that should bring in a big list of available packages

dpsutton16:01:10

and we will C-s for cider

dpsutton16:01:26

when your cursor is on that line hit i for install and then x for execute

stanislav16:01:50

I don't see cider in the list

dpsutton16:01:04

ah i don't think you have melpa enabled in this emacs

stanislav16:01:17

cider is back in that folder

dpsutton16:01:21

(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)

stanislav16:01:54

I have the stable melpa

stanislav16:01:02

I think I already did this once - removed cider completelly

dpsutton16:01:16

and in your startup you require it

stanislav16:01:17

could it be that it was autodownloaded?

dpsutton16:01:31

(dolist (p my-packages)
  (when (not (package-installed-p p))
    (package-install p)))

dpsutton16:01:36

is from your init i tihnk

dpsutton16:01:04

we should have a new cider then

stanislav16:01:12

yes, it's 0.14.0 then

dpsutton16:01:23

can you go to a clojure file and try to jack in?

stanislav16:01:59

It's the same issue

stanislav16:01:01

Should we stop here?

stanislav16:01:26

I mean, you've spent already quite a lot of time

stanislav16:01:32

trying to help me out

stanislav16:01:44

if you want to continue

stanislav16:01:48

I'm good for it

dpsutton16:01:55

i'm down to continue

stanislav16:01:56

(just giving you a way out 🙂 )

dpsutton16:01:01

let's keep trying

stanislav16:01:17

what should I try next?

stanislav16:01:32

should we switch to private channel?

dpsutton16:01:37

yeah let's do that

vinnyataide20:01:24

hello I just entered cider-debug mode but when I press n it just displays n in the screen

vinnyataide20:01:44

how can I step further into my fn

vinnyataide20:01:52

I did C-u C-M-x in the top fn form

vinnyataide20:01:45

oh I guess I have to call it

vinnyataide20:01:50

wow this is awesome!