reveal

jlmr 2022-02-20T11:46:54.900659Z

I’m trying to cleanly integrate Tutkain (Clojure plugin for Sublime Text) with reveal. Tutkain only works with plain socket repls so I’ve been trying the following (shamelessly copied from inspired by @seancorfield): I have the following mini-library:

(ns jlmr.socket-reveal
  (:require
   [clojure.core.server :as s]
   [clojure.main :as m]
   [vlaaad.reveal :as r]))

(defonce ui (atom (r/ui)))

(add-tap @ui)

(defn- submit-eval
  [form]
  (let [value (eval form)]
    (@ui value)
    value))

(defn repl
  []
  (m/repl :init s/repl-init :read s/repl-read :eval submit-eval))
And I have the following alias in my deps.edn:
{:extra-deps {vlaaad/reveal {:mvn/version "RELEASE"}
              jlmr/socket-reveal {:local/root "/Users/jelmer/Code/socket-reveal"}}
   :jvm-opts ["-Dclojure.server.repl={:address,\"0.0.0.0\",:port,50505,:accept,jlmr.socket-reveal/repl}"]}
When I connect to the socket repl with Tutkain, as expected the Reveal ui appears. However values don’t appear in Reveal when I eval them from the editor. Anyone any idea how I can fix this?

vlaaad 2022-02-21T09:50:28.366159Z

Hmm, can't you use r/repl? It's basically the same thing, but with submitting to Reveal window built in

jlmr 2022-02-21T10:29:08.688419Z

@vlaaad I did try r/repl, but I prefer r/ui 🙂

vlaaad 2022-02-21T10:29:56.381129Z

May I ask why? It supports all m/repl options...

vlaaad 2022-02-21T10:34:40.667929Z

r/repl is basically a wrapper of m/repl with all the necessary wrappings to give the best repl experience

vlaaad 2022-02-21T10:36:45.663799Z

r/repl is very similar to jlmr.socket-reveal/repl…

vlaaad 2022-02-21T10:37:58.169369Z

https://github.com/vlaaad/reveal/blob/master/src/vlaaad/reveal/repl.clj — here is r/repl source, it’s mostly the same, but it also wraps printing and showing thrown exceptions, adds a tap sink…

jlmr 2022-02-21T10:47:12.173859Z

Basically I like the ui of r/ui better, the fact that you can open extra panels at the bottom etc. Or have I missed that that’s possible with r/repl as well?

vlaaad 2022-02-21T10:47:49.107199Z

It’s totally possible

vlaaad 2022-02-21T10:48:48.294409Z

r/repl is a wrapper of m/repl that forwards repl output to r/ui

jlmr 2022-02-21T10:51:08.715869Z

I’m not sure I understand correctly: so I connect Tutkain to a socket-repl :accepting vlaaad.reveal/repl , connect Tutkain to it and then…. evaluate something to open the regular ui?

vlaaad 2022-02-21T10:51:31.683769Z

mm no, I connected to a simple clojure.core.server/repl

vlaaad 2022-02-21T10:52:11.792809Z

I took this example from tutkain readme:

clj -J-Dclojure.server.repl="{:port 5555 :accept clojure.core.server/repl}"

jlmr 2022-02-21T10:52:41.524849Z

and then open another nested vlaaad.reveal/repl I guess. I will try that out later today

vlaaad 2022-02-21T10:52:44.710469Z

and only changed it to add reveal to its classpath, e.g. clj -A:reveal -J…

vlaaad 2022-02-21T10:53:28.986649Z

I connected to it, and then run ((requiring-resolve 'vlaaad.reveal/repl))

flowthing 2022-02-21T10:53:37.530949Z

Yeah, so what you do now, but instead of ((requiring-resolve 'jlmr.socket-reveal/repl)), do ((requiring-resolve 'vlaaad.reveal/repl)).

vlaaad 2022-02-21T10:53:47.088799Z

yes

jlmr 2022-02-21T10:54:44.317309Z

Yes tried it out quickly and it works perfectly!!!

🎉 2
jlmr 2022-02-21T10:54:47.773269Z

Thanks both!

vlaaad 2022-02-21T10:57:58.541539Z

To summarize: 1. start a normal repl with reveal on the classpath: clj -Sdeps '{:deps {vlaaad/reveal {:mvn/version "1.3.265"}}}' -J-Dclojure.server.repl="{:port 5555 :accept clojure.core.server/repl}" 2. In sublime, use tutkain to connect to localhost:5555 3. evaluate ((requiring-resolve 'vlaaad.reveal/repl))

💯 1
☝️ 1
jlmr 2022-02-21T11:01:42.862499Z

Also has the benefit of being much simpler than what I was trying

jlmr 2022-02-21T11:02:16.434409Z

So in this case simple was actually easy as well 😅

1
flowthing 2022-02-20T14:59:16.977499Z

Hey there! Glad to see a Tutkain user in the wild. 🙂 I’ll be able to help you more when I'm front of my computer, but evaluating (jlmr.socket-reveal/repl) after connecting with Tutkain might work.

flowthing 2022-02-20T15:12:50.872789Z

I don't use Reveal a lot myself, but this is definitely a use case I want Tutkain to support, so if you encounter any issues or rough edges, I'd like to hear about them so I can fix them. Would you prefer evaluation results to only show up in Reveal and not have them show up in Tutkain at all?

jlmr 2022-02-20T16:47:20.285409Z

Hi! Yes after years of messing with Atom and VS Code I’m trying to get back to my first editor of choice, but I’ll have to get a decent Clojure experience going there before I can really make the switch back.

jlmr 2022-02-20T16:48:38.257439Z

I’ll try your suggestion tonight, but I’m having trouble understanding why it would help. jlmr.socket-reveal/repl is called just as Tutkain connects and all evaluations should be passed to it.

flowthing 2022-02-20T16:49:15.254039Z

It works because Tutkain starts its own REPL immediately after connecting.

jlmr 2022-02-20T16:49:19.016659Z

Tutkain can connect and forms evaled in the editor seem to work.

jlmr 2022-02-20T16:49:35.992279Z

Ah

jlmr 2022-02-20T16:49:57.437869Z

I assume that’s how Tutkain implements breaking evaluations and so on?

flowthing 2022-02-20T16:50:06.886819Z

That's part of it, yes.

jlmr 2022-02-20T16:50:27.049039Z

Ok good to know, will tinker on it more later today.

jlmr 2022-02-20T16:50:34.033159Z

Thanks!

flowthing 2022-02-20T16:51:08.910069Z

Sure thing. I'd be happy to help if you come across any issues or if there's some way I can improve Tutkain to make working with Reveal easier. Feel free to join #tutkain and hit me up there if necessary.

👍 1
jlmr 2022-02-20T17:29:19.107259Z

I indeed got it working by connecting to a regular socket and binding a key to evaluate ((requiring-resolve 'jlmr.socket-reveal/repl)) . Only oddity I notice that each time I switch tabs the namespace symbol gets evaluated or something and appears in reveal.

flowthing 2022-02-20T17:31:02.194979Z

Indeed — Tutkain auto-switches namespaces by default. You'll probably want to disable that in Tutkain's settings (Preferences » Package Settings » Tutkain on macOS), auto_switch_namespace.

flowthing 2022-02-20T17:33:13.924639Z

A feature that lets you automatically evaluate code after connecting might be useful... will think on that.

jlmr 2022-02-20T18:43:39.935209Z

Thanks! I think you’ve got yourself another Tutkain user 🙂

flowthing 2022-02-20T19:07:07.004449Z

Cool! That makes you user number three, I believe. 😛

🤯 1
flowthing 2022-02-20T19:18:36.983009Z

Oh, in case you only want your evaluation results to show up in Reveal (and not in Tutkain at all), you might want to add "output": "panel" to your tutkain_connect key binding and set auto_show_output_panel (new in 0.13.0, just released) to false.