Fork me on GitHub
#cider
<
2017-10-03
>
bigdaddys1oth03:10:04

Ya know...just going back to a previous version sounds much simpler.

dpsutton13:10:51

so @boogie666 we need to find cider.el

boogie66613:10:04

if i go to the .clj file and do same i did before i can find the cider--connected--handler function

dpsutton13:10:16

awesome. that means cider was loaded

boogie66613:10:23

problem is that pressing "enter" does not open it

dpsutton13:10:23

ok. are you in that function definition now?

boogie66613:10:41

the function definition

boogie66613:10:55

it just shows up in the window

dpsutton13:10:34

cool. visit that function

boogie66613:10:42

pressing "enter" with the function selected does nothing

dpsutton13:10:16

are you sure you have that function selected? maybe just try to find-function on cider-mode or something similar

dpsutton13:10:21

we just want to get into that directory somehow

dpsutton13:10:28

if emacs helps us get there easier just taken any avenue

boogie66613:10:31

actually it says Symbol’s value as variable is void: helm-bookmark-map

dpsutton13:10:40

ah ok. so something is going wrong with helm

boogie66613:10:53

i'm new here 😛

dpsutton13:10:57

no problem at all

dpsutton13:10:13

well, welcome to emacs, where things usually work nicely and often dont 🙂

dpsutton13:10:27

can you visit ~/.emacs.d/

dpsutton13:10:35

we can just root around for the downloaded source

dpsutton13:10:08

ever used dired before?

boogie66613:10:13

one sec i'll try to find cider

dpsutton13:10:36

ok. do spc spc dired and it'll ask you which directory and let's go to ~/.emacs.d/

dpsutton13:10:00

navigate as normal, hit enter to go to directory or file, and hit ^ to go up a directory

dpsutton13:10:10

we'll root around until we find the elpa directory

dpsutton13:10:54

awesome! search for cider, should be a directory like cider-23423423423432 something like that

dpsutton13:10:02

go to that directory and we want cider.el

boogie66613:10:21

ok, i'm there

dpsutton13:10:32

awesome. now search for cider--connected-handler

dpsutton13:10:49

(defun cider--connected-handler ()
  (let ((cider-enlighten-mode nil))
    (cider-make-connection-default (current-buffer))
    (cider-repl-init (current-buffer))
    (cider--check-required-nrepl-version)
    (cider--check-clojure-version-supported)
    (cider--check-middleware-compatibility)
    (cider--subscribe-repl-to-server-out)
    (when cider-auto-mode
      (cider-enable-on-existing-clojure-buffers))
    (sleep-for 0.1) ;; <-- Increase timeout till it works 
    (cider--debug-init-connection)
    (run-hooks 'cider-connected-hook)))

dpsutton13:10:02

so there's a line (when cider-auto-mode ...

dpsutton13:10:11

we want to put in a sleep expression right after that

dpsutton13:10:30

the bug has to do with loading classes not being done yet when we try to invoke it

dpsutton13:10:40

so we're just giving time for the jvm to finish its thing (i think)

dpsutton13:10:55

so add in that line (sleep-for 0.1) or longer if you want to be extra safe

boogie66613:10:32

ok, let me test it out

dpsutton13:10:48

did you re-evaluate the defun?

boogie66613:10:58

i restarted emacs 🙂

dpsutton13:10:59

we modified the source code but we need to eval it

dpsutton13:10:02

ah well, that should do it

dpsutton13:10:10

you're now an elisp programmer 🙂

boogie66613:10:17

yey 🙂

boogie66613:10:20

it worked 🙂

dpsutton13:10:22

your editor is super extensible. and you obvoiusly like lisps

boogie66613:10:23

💋 💋 💋

dpsutton13:10:29

awesome. haha you're super welcome

boogie66613:10:10

i've been using atom with proton-mode so far and thought i'd give spacemacs a try for a little bit 🙂 looks like i'm back in business 🙂

dpsutton13:10:52

good. sorry for the hiccup. but emacs is super great and has really been nice. its so nice that its just an elisp ide that happens to edit text pretty well

boogie66613:10:40

everybody keeps saying that emacs is great OS, it just needs a good text editor 😛

dpsutton13:10:19

for sure. and understandably people love vim interaction so spacemacs has got a lot going for it

boogie66613:10:19

anyway, thx a lot

dpsutton13:10:25

for sure. happy coding

boogie66613:10:28

cheers 🙂

andrea.crotti13:10:59

anyone having this issue?

andrea.crotti13:10:03

nREPL server started on port 56754 on host :: - nrepl://:::56754
[2017-10-03 14:27:43,717] ERROR Unhandled REPL handler exception processing message {:op init-debugger, :print-level 10, :print-length 10, :session e25f7710-305d-4e6e-a3ca-176d8f861ea4, :id 6} (clojure.tools.nrepl.server)
java.lang.IllegalAccessError: with-safe-transport does not exist, compiling:(cider/nrepl/middleware/info.clj:1:1)

andrea.crotti13:10:20

on 0.16.0snapshot?

dpsutton14:10:13

See the conversation above. It's how to introduce a temporary fix

dpsutton14:10:13

@andrea.crotti

andrea.crotti15:10:22

yes ok that makes it works, thanks @dpsutton

andrea.crotti15:10:36

I'll keep that around until there is another fix of some sort

dpsutton15:10:44

awesome. if you are feeling more investigative, there's a patch to nrepl you can try and report if that fixes

dpsutton15:10:11

you need to clone a fork of cider-nrepl and lein install it. takes substantially more work so not necessary if you're trying to get other things done

andrea.crotti15:10:35

ah yes ok I'll see it if fixes it, however it's not an OSS project what I'm working on now so would be maybe better to reproduce it on something I can show

dpsutton15:10:48

understood. i'm in the same boat here

andrea.crotti15:10:48

it depends on the dependencies from my understanding

andrea.crotti15:10:17

mm odd now I tried to debug a function and I get

1. Unhandled java.lang.Exception
   Debugger not initialized!

andrea.crotti15:10:49

don't think it's related but I've never seen that before, anyone knows what it could be the problem?

dpsutton15:10:41

did you happen to clobber anything when editing that function?

dpsutton15:10:53

(defun cider--connected-handler ()
  (let ((cider-enlighten-mode nil))
    (cider-make-connection-default (current-buffer))
    (cider-repl-init (current-buffer))
    (cider--check-required-nrepl-version)
    (cider--check-clojure-version-supported)
    (cider--check-middleware-compatibility)
    (cider--subscribe-repl-to-server-out)
    (when cider-auto-mode
      (cider-enable-on-existing-clojure-buffers))
    (sleep-for 0.1) ;; <-- Increase timeout till it works 
    (cider--debug-init-connection)
    (run-hooks 'cider-connected-hook)))

dpsutton15:10:04

note the line right after is (cider--debug-init-connection)

twillis15:10:09

Fwiw installing a new version of cider-nrepl per the instructions in the issue I reported fixes things so I no longer have an issue

andrea.crotti16:10:56

mm well I didn't edit anything I just redefined it @dpsutton

dpsutton16:10:11

if you didn't edit it, then you changed nothing. i'm not sure i follow. did you just paste the above or did you add the one line that fixes the problem: (sleep-for 0.1)?

andrea.crotti16:10:20

@dpsutton I just copied that function in ielm

andrea.crotti16:10:28

which evaluates it re-defining the original one

andrea.crotti16:10:00

I prefer to do that than changing a file not under revision control

dpsutton16:10:07

understandable for sure

dpsutton16:10:15

then i'm out of ideas. assuming the above is correct. maybe past that into the elisp repl or whatever you are using and make sure all of the names are spelled correctly?

pre19:10:44

Is there a reason why cider-format-buffer won't work on large edn files?

dpsutton19:10:04

what error are you seeing?

pre19:10:14

no error, it just doesn't format.

dpsutton19:10:03

ah, strange

pre19:10:02

it's a file with a list of maps generated by pr-str.

dpsutton19:10:27

there's a way to change the pretty printer. perhaps the one you have isn't good with your data. if its long strings or heavily nested maps perhaps?

pre19:10:27

I've been trying many "ways" for three years in cider, and still can't get a reliable formatting for edn files.

dpsutton19:10:20

and apologies if i'm telling you something you've tried a long time ago

pre19:10:02

yes I have, cider includes it and I have my tab keybinding set to it.

dpsutton19:10:26

i'm trying to remember how to see the nrepl traffic. i think the toggle function has been renamed

dpsutton19:10:46

i wonder if its abandoning with some kind of message?

pre19:10:33

where can i see the logs?

dpsutton19:10:37

M-x nrepl-toggle-message-logging maybe see what the call to format the edn is returning

dpsutton19:10:55

that talks about how you can see what cider and nrepl are saying to each other

dpsutton19:10:06

maybe there's some response coming back with more information than cider is displaying?

pre19:10:17

I get a response as "done"

(<--
  id             "95"
  session        "917da08e-ebb3-4e5e-8492-16bcaf6716e5"
  time-stamp     "2017-10-03 12:16:41.289718364"
  formatted-code "({:uri "chef_module", :name "chefnode1", :kind :chef_node, :..."
  status         ("done")
)

dpsutton19:10:49

and the formatted-code will contain the payload

pre19:10:04

you can try this in your own cider: Create a map with three keys, repeat 500, and spit it using pr-str. Now, try to format it.

dpsutton19:10:35

sorry i'll try this in about ten minutes

dpsutton19:10:20

and is this lacking newlines between the structures? my worry is that this is long lines and guessing new lines running up against 20,000 characters in a row

pre19:10:34

every single editor does that for json, I don't see a reason not to provide a default in cider.

dpsutton19:10:01

oh for sure. it should but i don't know if it does

pre19:10:30

that's what I'm trying to figure out, if it's an easy el script ... could copy that in my emacs ...

dpsutton19:10:56

i think emacs might use pprint by brandon bloom by default. this is not simple code.

dpsutton19:10:04

sorry i mean fipp

dpsutton19:10:12

but i'm sure contributions are welcome

pre19:10:00

If your day job involves parsing large edn files (who doesn't do that :)) I'm positive that formatting and paredit navigation to edn structures is a massive help.

dpsutton19:10:38

undoubtedly. just need one of those busy people to code something up 🙂

pre19:10:00

Seems like cider has been busy for years fixing other bugs 🙂

pre19:10:40

I'd like to help if you can point me to the right direction ....

dpsutton19:10:11

looks like here

dpsutton19:10:29

wrote this about getting started with cider-nrepl

dpsutton19:10:10

if this is your first time getting up and going, keep notes and would love tutorials, code walkthroughs, newbie instructions, overviews, whatever, you want to submit as a PR to hacking-cider. it's just a collection of markdown files to get people going

pre19:10:05

How do I customize wrap-pprint-fn middleware?

dpsutton19:10:58

i'm not sure what you mean

dpsutton19:10:57

i think you choose your pretty printer in cider

(defun cider--pprint-fn ()
  "Return the value to send in the pprint-fn slot of messages."
  (pcase cider-pprint-fn
    (`pprint "clojure.pprint/pprint")
    (`fipp "cider.nrepl.middleware.pprint/fipp-pprint")
    (`puget "cider.nrepl.middleware.pprint/puget-pprint")
    (_ cider-pprint-fn)))

dpsutton19:10:04

not sure if that's what you're asking about however

dpsutton19:10:38

and you can see the middleware here reads the pprint-fn var set in the message:

defn pprint-reply
  [{:keys [pprint-fn session transport] :as msg} response]
  (with-open [writer (pprint-writer msg)]
    ;; Binding `*msg*` sets the `:id` slot when printing to an nREPL session
    ;; PrintWriter (as created by `pprint-writer`), which the client requires to
    ;; handle the response correctly.
    (binding [*msg* msg
              *out* writer]
      (let [value (cljs/response-value msg response)
            print-fn (if (string? value) println pprint-fn)]
        (print-fn value))))
  (transport/send transport (response-for msg :pprint-sentinel {})))

dpsutton19:10:03

{:keys [pprint-fn]is how elisp and clj are connected

dpsutton19:10:20

@pri did that answer your question? i didn't meant to spend a lot of time on irrelevant or things you already knew

pre19:10:58

Thanks @dpsutton What do I need to add in my config?

pre19:10:35

I have added fipp and ultra in ~/.lein/profiles.clj the past (no luck)

dpsutton19:10:44

to change the var used (and i'm not totally sure this is actually used in formatting end) set the var cider-pprint-fn. in your init you can (setq cider-pprint-fn 'fipp) or use the customize menu

pre19:10:19

That didn't work.

pre19:10:09

The more important question--as I've run through this issue for three years, is: why is cider reluctant to provide a sensible default?

dpsutton19:10:45

default for what?

pre20:10:04

formatting and navigating edn files.

dpsutton20:10:25

i think it has built in to format edn? and it defaults to the clojure pretty printer.

dpsutton20:10:31

maybe this is a bug for them? i dont' know

dpsutton20:10:39

but as defaults go that's pretty sensible

dpsutton20:10:58

honestly i bet this is one area where cursive really shines

pre20:10:08

a default that doesn't do anything is useless, IMHO

dpsutton20:10:09

big data structures. emacs just isn't very good with long lines

dpsutton20:10:27

i'm pretty sure we're in a "default doesn't do anything in this situation" type of situation

dpsutton20:10:36

but i take your point

pre20:10:31

Thanks for your time. For now, it's Intellij for edn files ...

dpsutton20:10:05

yeah. i'll bet it will excel at it. lodge an issue? i may not know enough to help you out and someone else can get you closer to your goal?

bschrag21:10:37

Can CIDER be configured to warn in case of a lein error? With a certain bug in my source code, lein repl tells me #error {:cause Unable to resolve symbol: Foo in this context ... }, then starts a REPL anyway with my project's namespace prompt. cider-jack-in just gives me the prompt, leaving it to me to discover that something is busted, then try to figure out what. Is there a better workflow than first running lein repl to make sure your project is qualified for cider-jack-in? Running Emacs 25.2.2, just installed CIDER today from Melpa-stable.