reveal

Docs: https://vlaaad.github.io/reveal/ Source: https://github.com/vlaaad/reveal
phronmophobic 2021-04-07T20:53:55.026300Z

Is there a way to access reveal's currently selected value? Sometimes I navigate into a nested value and then want to play with that from the repl (closing the reveal loop). Maybe something like *r as an analog to *1?

vlaaad 2021-04-08T07:24:04.030500Z

I’ve been thinking about that before 🙂 In general it’s not possible since we usually have repls that are unaware of reveal, e.g. how would you do that with remote prepl? Eval is in different process that has no way to access Reveal… But it’s possible to create local repls that ARE aware of reveal, and maybe built-in repl could have their eval augmented to access currently selected value.

phronmophobic 2021-04-08T07:36:05.030700Z

Some possibilities • maybe a function call that just asks reveal what its currently selected value is • a reveal command that sets a callback to be called whenever the currently selected value changes. Then I can use that callback to put the latest value wherever it's convenient • Since it's only for development, it might it even make sense to intern a var in clojure.core like *r that gets updated with the latest selection. This option would make it easier to share workflows

vlaaad 2021-04-08T07:44:28.031Z

Good suggestions! One reason I haven’t done this so far (besides higher prio stuff) is because I think there might be another way to

vlaaad 2021-04-08T07:44:39.031200Z

..oops, hit enter too fast 😄

😆 1
vlaaad 2021-04-08T07:46:23.031400Z

Anyway, I think there is another issue that could be fixable with access to selection in one swoop: there is no sharing of bindings between reveal’s eval on selection and user’s repl

vlaaad 2021-04-08T07:48:13.031600Z

for example, using (prn *v) in eval-on-selection popup will print… somewhere, but not in Reveal’s UI, while using (prn :foo) with reveal-connected repl will print both to reveal and to process’ out

phronmophobic 2021-04-08T07:50:25.031900Z

does reveal know what the currently selected namespace is?

vlaaad 2021-04-08T07:50:54.032100Z

nope, and this is another problem in this area

phronmophobic 2021-04-08T07:51:10.032300Z

not sure it does, but if it did, then there could be an option to def a var in the current namespace

phronmophobic 2021-04-08T07:51:16.032500Z

oh, bummer

vlaaad 2021-04-08T07:51:17.032700Z

but I guess *ns* is a part of those bindings

phronmophobic 2021-04-08T07:51:31.032900Z

true

vlaaad 2021-04-08T07:52:22.033100Z

so if/when I figure this stuff out, maybe (def foo *v) will pick a better ns than clojure.core

vlaaad 2021-04-08T07:53:19.033300Z

like user , or ns that was active when reveal repl was started, or ns from latest eval… this needs some more hammock time

👍 1
phronmophobic 2021-04-08T07:58:51.033700Z

if you don't have enough options, you could also create a reveal namespace named something short like r or reveal. Then it's easy to use from the repl with r/*v , r/my-saved-val, etc.

phronmophobic 2021-04-08T07:59:06.033900Z

you wouldn't even need to require the namespace since it would be fully qualified

phronmophobic 2021-04-08T07:59:33.034100Z

so it would work regardless of which namespace you're working in

phronmophobic 2021-04-08T08:00:40.034300Z

the main benefit is that you wouldn't have to add requires in namespaces just to access reveal values

phronmophobic 2021-04-08T08:05:39.034600Z

the main downside is that short names are more likely to clash with common aliases

teodorlu 2021-04-08T20:23:53.037500Z

why not just a normal namespace like reveal.repl/*v ? Optionally other namespace / other name for *v. I woudn't consider (require '[reveal.repl :refer [*v]]) in user.clj too much of a hassle. I'm assuming it's not possible to connect multiple reveal processes? Caveat: Reveal noob, this might not make sense.

phronmophobic 2021-04-08T20:31:07.037900Z

@teodorlu, for my personal workflow, I might be working in several different namespaces at once, so remembering to run (require '[reveal.repl :refer [*v]]) in each namespace I might be in adds enough friction that I probably wouldn't use it that often

wilkerlucio 2021-04-08T20:32:57.038100Z

hooking on what @teodorlu said, that could be a thing Reveal does, when the user changes the selection on reveal, reveal updates reveal.repl/*v (that value being an atom or something) to reflect that reference, maybe that’s what @teodorlu was saying

➕ 1
phronmophobic 2021-04-08T20:37:57.038400Z

updating reveal.repl/*v makes sense. I was hoping for a shorter name for reveal.repl/*v like r/*v

wilkerlucio 2021-04-08T23:17:08.038600Z

@smith.adriane to deal with the long names I would make a live template (aka snippet) to expand something like rv to @reveal.repl/*v

wilkerlucio 2021-04-07T21:17:54.026400Z

*v

wilkerlucio 2021-04-07T21:18:29.026600Z

eg: (name *v)

phronmophobic 2021-04-07T21:19:07.026800Z

that doesn't seem to work from my normal repl

phronmophobic 2021-04-07T21:20:48.027Z

it works in reveal, but I was looking for something that I could use in my editor

wilkerlucio 2021-04-07T21:22:33.027200Z

ah, sorry, I misunderstood the question, from REPL I dunno

phronmophobic 2021-04-07T21:22:49.027400Z

but *v seems helpful in other situations :thumbsup:

wilkerlucio 2021-04-07T21:23:33.027800Z

one idea, what if do (def something *v) from Reveal?

wilkerlucio 2021-04-07T21:24:07.028Z

just tested, it seems to def the thing under clojure.core, haha

wilkerlucio 2021-04-07T21:24:17.028200Z

I guess with a bit more code we can switch the ns and def somewhere else

wilkerlucio 2021-04-07T21:24:26.028400Z

or put an atom somewhere, and reset! that atom

phronmophobic 2021-04-07T21:43:06.029300Z

I guess I could create a plug-in that does something similar

phronmophobic 2021-04-07T21:43:34.030200Z

seems like having a way to “close the loop” would be generally useful

👍 1