Fork me on GitHub
#cider
<
2018-03-26
>
stardiviner01:03:42

Hi, @bozhidar Will you add ob-clojure.el header argument :ns support as you mentioned in this https://github.com/clojure-emacs/clojure-mode/pull/465#discussion_r158009538 ?

bozhidar02:03:13

@arrdem Surely. Reviewing this is on the top of my todo list. I hope I’ll ge to do this today.

bozhidar02:03:52

@stardiviner I’ve not sure what I’m supposed to do with this. I see org seems to now set the buffer-local cider-buffer-ns, which means that the evaluation should work properly now.

stardiviner02:03:57

@bozhidar No, it is in ob-clojure-literate extension. In ob-clojure, still not solved.

stardiviner02:03:40

That's why I use buffer-local dynamically change it in ob-clojure-literate by always retrieve the ns before evaluation.

arrdem02:03:36

@bozhidar thanks, I really appreciate it. Got cask set up on my machine and trying to stomp down the lint issues / work down the contrib checklist.

dpsutton02:03:35

@arrdem did you see my message about you trampling the :transport of the message?

dpsutton03:03:11

and ps, the feature looks super cool 🙂

arrdem03:03:14

@dpsutton I did. Can you clarify the particular concern? the pprint middleware which is what I worked off of does more or less the same thing.

arrdem03:03:44

Thanks 😛 I was doing a bunch of traffic graphing at work and got sick of having to re-open my graphs in another tool.

arrdem03:03:29

despite being a many-year CIDER/nREPL user this is my first dive into all of this, so I make no claim to know what I'm doing.

arrdem03:03:43

It's been interesting to finally get my head around some of the middleware and transport stuff.

dpsutton03:03:03

i'm a little confused about that.

(def ops-that-can-eval
  "Set of nREPL ops that can lead to code being evaluated."
  #{"eval" "load-file" "refresh" "refresh-all" "refresh-clear"
    "toggle-trace-var" "toggle-trace-ns" "undef"})

(defn handle-tracker [handler msg]
  (if (ops-that-can-eval (:op msg))
    (handler (assoc msg :transport (make-transport msg)))
    (handler msg)))
this is from track state. it seems like they should clobber each other and only one should work

dpsutton03:03:02

so i'm a little confused as well

arrdem03:03:05

So the problem that both the pprint middleware and my content-type middleware face is they have to intercept the produced result value and change how it gets interpreted.

arrdem03:03:24

because pprint ... pprints it and I try to find another "richer" interpretation for it.

arrdem03:03:50

the pprint middleware works by creating a wrapping transporter, which delegates to the wrapped (default) transport.

arrdem03:03:56

That's basically what I'm trying to do.

dpsutton03:03:03

ah you are right. i'm sorry

arrdem03:03:10

no worries!

dpsutton03:03:24

i saw the assoc :transport and forgot that you were using the existing msg in it and calling its current transport

arrdem03:03:56

It took me quite a while to get my head around that and I blew up several nREPLs. Turns out you can't println debug from the thing that handles printlns >.>

dpsutton03:03:20

yeah it gets weird. when i make changes its super slow because i lein install and then go run it with something else

dpsutton03:03:30

not a quick feedback loop

arrdem03:03:52

I did most of the dev for this actually in the cider-nrepl project which worked fairly well.

arrdem03:03:14

but yeah when I had to change the actual middleware instead of any of its delegate functions that sucked.

arrdem03:03:42

I gotta say I don't agree with some of these elisp-lint requirements

arrdem03:03:05

the argument is named "buffer" what on earth do you think it's used for

stardiviner03:03:07

@arrdem Can yo explain a little how it works about content-type middleware? I wish to use it in ob-clojure-literate. I need to save result image to a working directory or specified directory.

arrdem03:03:00

@stardiviner there's really not much to explain - emacs supports inserting images either from raw binary data or from a file path. All the work I've done does is wire up nREPL to recognize some kinds of Java objects as images and flag those results so Emacs can hook into them and work with them.

arrdem03:03:51

Particularly if you return a File (or a URI) to something, then send an nREPL response with the content-type of the file and its path.

arrdem03:03:32

If you return a Java Image instance, then there's some fancy footwork to actually generate a base64 of the image as a PNG and ship that back in the nREPL response.

stardiviner03:03:39

So it should support Clojure libraries like Incanter?

stardiviner03:03:26

Does it support to save the response image to somewhere?

arrdem03:03:28

You may want to write your own extensions to dump anonymous returned images to files. The tools I was working to wrap up all generate tempfiles anyway.

arrdem03:03:34

^ no it doesn't.

stardiviner03:03:29

Can I think your middleware like a uniform of all image objects. Then display this uniform image object in Emacs CIDER REPL? If so then I should be able to save the object's image to other place, right?

arrdem03:03:59

Yeah it shouldn't be too hard to tweak the handlers to save images somewhere if you want to.

arrdem03:03:18

Specifically you'd want to provide an alternative image/png;base64 handler.

stardiviner03:03:18

That's great!

stardiviner04:03:36

After your explaintion, now I can understand your code. BTW, will your add some examples in CIDER documentation?

bozhidar04:03:32

> the argument is named “buffer” what on earth do you think it’s used for

bozhidar04:03:20

Something about docstring, right? Those are requirements by Emacs itself. All parameters have to be mentioned in the docstrings of their functions. Emacs is really big on documenting functions.

stardiviner11:03:19

If I don't specify "user" in nrepl eval request. Then it works fine.

stardiviner11:03:39

Why I use (nrepl-sync-request:eval expanded (cider-current-connection)) Emacs flycheck report warning "nrepl-sync-request:eval called with 2 arguments, but requires 3-4" Weird. Because I saw the parameters NS is after &optional. It should not report this warning.

bozhidar11:03:42

There’s a difference between a norma (async) eval and a sync eval. An async eval (like the one you used in this example), also needs a response handler.

stardiviner12:03:26

No matter (nrepl-sync-request:eval or nrepl-request:eval, both parameter NS is optional. In question 1, he should be defined under namespace kk.test, but the whole request eval returned "out" is user/he. That's weird. don't know why.