This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-16
Channels
- # atom-editor (6)
- # babashka (31)
- # beginners (34)
- # calva (1)
- # cider (21)
- # clj-kondo (5)
- # cljsrn (2)
- # clojars (6)
- # clojure (35)
- # clojure-europe (3)
- # clojure-norway (2)
- # clojurescript (4)
- # conjure (10)
- # crux (4)
- # cursive (8)
- # data-science (78)
- # fulcro (23)
- # graphql (10)
- # helix (2)
- # luminus (1)
- # off-topic (50)
- # other-languages (1)
- # pathom (8)
- # re-frame (9)
- # reagent (9)
- # reitit (1)
- # rewrite-clj (6)
- # shadow-cljs (134)
- # tools-deps (53)
- # vscode (1)
hello, there's a way to redirect output of cider-eval-print-last-sexp
to kill-new
?
(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))
'()))

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

(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)))))
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.
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
newbie question, how can I see the type of some output on elisp? there is a (type output)
?
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
It has some destructuring support today ((e.g. pcase-let
), but it didn't have it 7 years ago. 😄