This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # 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
(defn clojure-function  (let [thing (eval-emacs-lisp (goto (point-min))...
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
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.
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
a, and scan back through the previous expressions, looking for the most recent
(defn followed by
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.
When navigating to source in a project that uses boot I always end up in the boot cache folder instead of the src folder, anyone knows why?