This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-26
Channels
- # bangalore-clj (1)
- # beginners (12)
- # boot (48)
- # cider (56)
- # clara (1)
- # cljs-dev (15)
- # clojure (455)
- # clojure-austin (2)
- # clojure-dev (33)
- # clojure-italy (26)
- # clojure-nl (6)
- # clojure-poland (10)
- # clojure-russia (23)
- # clojure-spec (33)
- # clojure-uk (62)
- # clojurescript (37)
- # code-art (2)
- # cursive (12)
- # datomic (48)
- # funcool (1)
- # juxt (16)
- # leiningen (13)
- # off-topic (12)
- # om (23)
- # onyx (16)
- # other-lisps (5)
- # parinfer (2)
- # pedestal (28)
- # re-frame (60)
- # reagent (8)
- # ring (1)
- # ring-swagger (15)
- # spacemacs (5)
- # specter (53)
- # test-check (2)
- # unrepl (8)
- # vim (14)
Found a bug in cider regarding pprint & load-file. I'm wondering if it's possible to view tools.nrepl's middleware ordering somehow? Quite important for diagnosing a full fix.
Does anyone know whether there are any affordances in CIDER for calling an emacs function (ie emacs lisp)? I'm playing with some ideas about automatically converting material from repl sessions to unit tests, and it would be awfully handy to be able to call some existing emacs functions. I have no reason to expect that there would be such affordances, but thought I'd ask ๐. Mostly I just want to access CIDER repl history from the current repl session.
@eggsyntax well you can call any required cider function from your own functions
what do you mean by affordances? maybe I don't understand this word in this context (not an English native speaker ๐ )
Oh, sorry, I skipped a critical part โ Iโm hoping I can somehow call emacs functions from Clojure. By affordances, I just meant some tools built into CIDER that make it possible/easier to do that. Basically Iโm hoping for a foreign function interface to emacs lisp ๐
oh no problem ๐ I have never tried it but there is this https://github.com/clojure-emacs/clomacs
something like
(defn clojure-function [] (let [thing (eval-emacs-lisp (goto (point-min))...
etc?but of course you have resort to passing chars around if you want to send stuff from/to the two worlds
@richiardiandrea hmm, Iโm not quite sure how I would do it even passing chars around.
I mean, I could, say, write a watcher fn in emacs lisp that runs in the background and watches for input on some channel, but Iโm hoping thereโll be at least a slightly better way ๐
emacs evals clojure in nrepl which evals emacs-lisp in emacs whic sends back to finish clojure which sends back to emacs
yeah โ๏ธ
that is passing chars around ๐
Thatโs why I hoped CIDER might have something built in to make that process a bit less painful ๐ . It didnโt seem terribly likely, but worth asking ๐
The simplest thing might be to figure out how to get CIDER to constantly auto-save repl history, and then just slurp the file ๐
Or else look how *1
(most recent output) is implemented, and build something similar for input instead of output.
(or just build the whole thing in emacs lisp, but that gets painful too, because ideally it should look back through history but filter out everything except valid clj expressions)
the tough thing is that this would have to interrupt the eval order of the clojure code. It seems like it would have to do that
and cider could be aware that it's a programmatic input rather than user typing input
Why would it have to interrupt the eval order of clj code? I'm not immediately seeing that.
emacs-read
is a builtin emacs fn? Or a clj fn in CIDER? Not finding a clear answer with a google search.
oh no, @eggsyntax that's not a real function. i was kinda thinking outloud
sure. but you probably don't want to write them as strings. so emacs-read would be a macro that would string it's whole argument and send it back to emacs
with the same or similar mechanism to just read from std-input but modified to return the executed code rather than the users input
(let [x (read-from-emacs (+ 1 1)) ...
would let you write data for (+ 1 1), the macro turns it into a string and sends it back to emacs
Ah, yeah, good thought. Seems like you could overcome clj trying to evaluate the forms by just quoting. '(+ 1 1)
I should probably say what I'm imagining, as long as you're being kind enough to help brainstorm ๐
I'm just thinking of something that'll start with the last expression you entered in the repl, say (f a 1)
. It'll recognize that it hasn't seen a definition for f
or a
, and scan back through the previous expressions, looking for the most recent (def
or (defn
followed by f
or a
. Those may themselves contain undefined terms, so it recurses into searching for definitions for those. It'd definitely be easier to do it robustly in clj/s (which eg recognizes built-in keywords & knows it doesn't need to find defs for those), but I suspect you could probably hack it together in emacs lisp if necessary. Then it just strings those expressions together in the order they were seen, so you've got a self-contained sequence of expressions ending in (f a 1)
. Those can then get wrapped up into a deftest
pretty easily, one which expects whatever the most recent return value was.
The idea is that it would just save you the hassle of putting those together into a unit test manually.
Nothing huge, but I would certainly create more unit tests if I could just do that -- I tend to test stuff in the repl as I'm writing it, and try to test in it smart ways (corner cases etc), but I often don't bother to put those together into an automated test.
yeah i've long wished i could take my repl exploration and make a unit test stating (is (= (last input) (last output))
finally get to a point on the repl that it's working and you've got the syntax that you like
Exactly. & then if you do try to create a unit test, you sometimes have to dig back through the repl history yourself to find that one variable you defined half an hour ago...
It seems possible, anyway. If it's not possible without a huge ugly hack, I may or may not go there ๐
so there needs to be a get-create-test-buffer function and then just insert the testing form of (is (= repl-input repl-output
Yeah, but since cider itself is emacs lisp, that's why I was expecting I'd have to make a couple of emacs lisp calls.
Oh, so you mean a lisp function get-create-test-buffer
. The only issue with doing it entirely in lisp is that it's harder to fully parse what's a valid definition, what needs to still be defined, what's a keyword or core fn, etc.