unrepl

discussing specification of an edn-based repl and its implementations.
pesterhazy 2017-12-04T11:08:42.000086Z

welcome @nblumoe 🙂

nblumoe 2017-12-04T11:08:52.000368Z

Hi @pesterhazy

nblumoe 2017-12-04T11:09:00.000099Z

Ready to take a noob question? 😄

pesterhazy 2017-12-04T11:09:09.000121Z

always!

nblumoe 2017-12-04T11:09:34.000406Z

Excellent 😄

nblumoe 2017-12-04T11:11:23.000190Z

So, I managed to communicate with a socket repl started with clj -J-Dclojure.server.repl="{:port 5555 :accept clojure.core.server/repl}". How do I get unrepl on that repl? Do I need to pass it via :accept? I was going to use the reference implementation from https://github.com/Unrepl/unrepl

nblumoe 2017-12-04T11:12:16.000094Z

the reference implementation has a start-aux function which seems to be the entry point…

nblumoe 2017-12-04T11:13:49.000288Z

I guess I could call that from the socket repl to get it going. But I am not so sure that I am doing the right thing here….

pesterhazy 2017-12-04T11:17:30.000067Z

@nblumoe do you want to use an existing client, or write your own?

nblumoe 2017-12-04T11:17:53.000341Z

own

pesterhazy 2017-12-04T11:20:29.000261Z

I'm trying right now

pesterhazy 2017-12-04T11:20:36.000068Z

how do I install clj?

pesterhazy 2017-12-04T11:20:43.000421Z

I'm asking the newb questions here @nblumoe

nblumoe 2017-12-04T11:21:14.000059Z

Mac? brew install clojure

pesterhazy 2017-12-04T11:21:26.000286Z

ah I tried "brew install clj"

pesterhazy 2017-12-04T11:22:22.000015Z

clj -J-Dclojure.server.repl="{:port 5555 :accept clojure.core.server/repl}"
Exception in thread "main" java.io.FileNotFoundException: -J-Dclojure.server.repl={:port 5555 :accept clojure.core.server/repl} (No such file or directory)

pesterhazy 2017-12-04T11:23:17.000184Z

haha

pesterhazy 2017-12-04T11:23:23.000011Z

I already had a script called clojure

nblumoe 2017-12-04T11:23:29.000241Z

😄

pesterhazy 2017-12-04T11:24:35.000319Z

lein unrepl-make-blob
rlwrap cat resources/unrepl/blob.clj - | nc localhost 5555

pesterhazy 2017-12-04T11:24:38.000025Z

gives you a nice prompt

pesterhazy 2017-12-04T11:25:34.000142Z

unrepl is usualy loaded by "upgrading" an existing basic repl (clojure.core.server)

pesterhazy 2017-12-04T11:25:57.000132Z

the advantage being no configuration on the serve side, other than opening the port

cgrand 2017-12-04T11:27:34.000214Z

and when unrepl doesn’t do what you want, you fork , patch it and use the resulting blob

pesterhazy 2017-12-04T11:28:04.000441Z

@cgrand maybe these two lines would make a nice addition to the unrepl readme?

cgrand 2017-12-04T11:28:07.000023Z

so you are free to experiment or have to wait for me to fix a bug

cgrand 2017-12-04T11:28:20.000276Z

(welcome @nblumoe btw)

nblumoe 2017-12-04T11:33:00.000150Z

Ok I see, thanks. (And actually I also remember now 😄 )

nblumoe 2017-12-04T11:33:53.000389Z

and blob.clj I am going to build via <https://github.com/Unrepl/unrepl/blob/master/tasks/leiningen/unrepl_make_blob.clj> right?

pesterhazy 2017-12-04T11:34:42.000255Z

right that's the lein unrepl-make-blob I mentioned

nblumoe 2017-12-04T11:47:34.000174Z

Cool thanks. Working from CLI now

baptiste-from-paris 2017-12-04T11:51:08.000089Z

hello all, does the scripts/loop is working for everyone ? e.g : rerun lumo after it has been killed

nblumoe 2017-12-04T11:53:32.000070Z

and also working from within my code now…. Thanks!

👌 1
cgrand 2017-12-04T12:27:01.000136Z

@nblumoe may I ask what you are doing? just toying around or more?

nblumoe 2017-12-04T12:29:49.000140Z

Sure, we would like to use it for Clojure code evaluation on https://nextjournal.com/

cgrand 2017-12-04T12:33:07.000271Z

cool

richiardiandrea 2017-12-04T16:07:38.000085Z

Quite nice (except the blue ;)) !

cgrand 2017-12-04T16:08:06.000189Z

I could even render classes and symbol differently

volrath 2017-12-04T16:12:22.000043Z

great!

pesterhazy 2017-12-04T16:23:31.000086Z

🎉

pesterhazy 2017-12-04T16:24:57.000484Z

iterm2 supports hover???

cgrand 2017-12-04T16:25:45.000587Z

that’s hyperlink detection, but it supports (and libvte too) true hyperlinks

pesterhazy 2017-12-04T16:26:39.000107Z

pretty sweet

cgrand 2017-12-04T16:27:03.000126Z

and I have seen in the propieraty escapes codes a thing about hints displayed on hover (and also sending a system notification)

pesterhazy 2017-12-04T16:27:45.000517Z

I mean we need to tread carefully here because we don't want to venture too far into detecting terminal types etc.

pesterhazy 2017-12-04T16:27:59.000064Z

but this looks potentially super useful

cgrand 2017-12-04T16:28:07.000591Z

I used none of those because of this

pesterhazy 2017-12-04T16:28:49.000469Z

ah, java.io.File is (incorrectly) detected as a URL

pesterhazy 2017-12-04T16:28:51.000638Z

got it now

pesterhazy 2017-12-04T16:29:08.000268Z

is that packed applying the colors?

cgrand 2017-12-04T16:29:50.000137Z

https://www.iterm2.com/documentation-escape-codes.html for iterm2

cgrand 2017-12-04T16:31:03.000426Z

it’s the unravel ansi rendering for packed

pesterhazy 2017-12-04T16:32:04.000504Z

you just interpret the [:span ...] data structures in a colored way?

cgrand 2017-12-04T16:33:24.000302Z

decoupling: packed only cares about the length of the spans (it doesn’t even know how to retroeve their content), so it computes a layout and then an application specific renderer do the actual rendering using extra fields or methods on spans

cgrand 2017-12-04T16:33:40.000422Z

(defn ansi [text ansi-text]
  {:length (count text)
   :text ansi-text
   :start-length (count text)
   :start-text ansi-text
   :br-after? true})

cgrand 2017-12-04T16:34:27.000301Z

creates a span, length, start-length and br-after are for packed; text and start-text are for the renderer

cgrand 2017-12-04T16:35:03.000336Z

so I (ab)use the text renderer by putting ansi escapes into the rendering

cgrand 2017-12-04T16:35:32.000144Z

it’s ok as long as the declared length is the displayed length

cgrand 2017-12-04T16:36:11.000066Z

(forgot to push)

cgrand 2017-12-04T16:37:50.000304Z

So the telling code sample is this cond clause:

(keyword? x) (let [s (str x)] [(ansi s (str “\33[36m” s “\33[m”))]) ; cyan

pesterhazy 2017-12-04T16:40:02.000622Z

cool

cgrand 2017-12-04T17:41:43.000489Z

@pesterhazy I havens created a PR for packed but it’s good to go.

cgrand 2017-12-04T20:59:53.000568Z

@pesterhazy I guess I found the ^J eater: https://github.com/nodejs/node/blob/master/lib/internal/readline.js#L401-L404