cider

A channel dedicated to the Clojure Interactive Development Environment that Rocks (aka CIDER). :cider:
2020-08-16T02:27:36.034200Z

hello, there's a way to redirect output of cider-eval-print-last-sexp to kill-new ?

bozhidar 2020-08-16T17:30:30.035Z

@d.ian.b Currently no.

dpsutton 2020-08-16T17:49:35.035800Z

(cider-interactive-eval "(java.util.UUID/randomUUID)"
                        (nrepl-make-response-handler nil
                                                     (lambda (_buffer value)
                                                       (kill-new value)
                                                       (message "copied %s" value))
                                                     (lambda (_buffer out)
                                                       (kill-new out)
                                                       (message "copied %s" out))
                                                     (lambda (_ err)
                                                       (message "error evaluating: %s" err))
                                                     '()))

1
dpsutton 2020-08-16T17:50:57.036800Z

that copies both out and returned values. not sure if that's what you want. but read the docstring for nrepl-make-response-handler. or you could check out the source of cider-interactive-eval and pass a single handler in there that does what you want

1
2020-08-16T17:52:13.037500Z

I've stopped on nrepl-make-response-handler trying to understand

2020-08-16T17:52:38.038100Z

first steps on emacs-lisp 😅

2020-08-16T17:52:45.038300Z

thanks @dpsutton

1
dpsutton 2020-08-16T17:58:47.038600Z

(cider-interactive-eval "(java.util.UUID/randomUUID)"
                        (lambda (response)
                          (nrepl-dbind-response response (value)
                            (when value
                              (kill-new (format "%s" value))
                              (message "copied %s" value)))))

bozhidar 2020-08-18T07:55:04.052700Z

Something like this will get the job done, but without the pprint that @d.ian.b asked for, so you might consider using its handler instead.

dpsutton 2020-08-16T17:59:15.038900Z

bit easier i suppose.

2020-08-16T18:01:30.039400Z

what is nrepl-dbind-response ?

2020-08-16T18:08:18.039700Z

wow, defmacro on elisp rs

2020-08-16T18:08:34.040200Z

I have to study more, thanks @dpsutton

dpsutton 2020-08-16T18:09:48.041400Z

your emacs should just go to definition if you hit m-. you can also use m-x apropos to read the docstring. but it should be a bit understandable: given a response from nrepl, bind the binding value to some notion of value in the repsonse. its essentially a dictionary that's defined somewhere in CIDER

2020-08-16T18:12:16.042900Z

yeah, I've put the entire dictionary on kill-new but it was not a stringp

2020-08-16T18:12:32.043600Z

newbie question, how can I see the type of some output on elisp? there is a (type output) ?

dpsutton 2020-08-16T18:12:34.043700Z

that would just be map destructuring in clojure. but emacs lisp doesn't have that functionality baked in. there are some macros that provide it but they are not super standard and have a bit of weird syntax

🤯 1
bozhidar 2020-08-18T07:53:02.052500Z

It has some destructuring support today ((e.g. pcase-let), but it didn't have it 7 years ago. 😄

dpsutton 2020-08-16T18:14:00.044700Z

if you step through the function with the debugger it should be pretty visible. define the form above in a function and then instrument it and then call it

✔️ 1
dpsutton 2020-08-16T18:14:32.045300Z

alternatively, check out nrepl-dict.el and its just a simple hashmap i believe

dpsutton 2020-08-16T18:15:24.046100Z

if you check out nrepl-make-response-handler you can see what it is using nrepl-dbind-response to capture

(nrepl-dbind-response response (content-type content-transfer-encoding body
                                                 value ns out err status id)

1