Fork me on GitHub
#unrepl
<
2017-12-04
>
nblumoe11:12:00

Ready to take a noob question? 😄

nblumoe11:12:34

Excellent 😄

nblumoe11:12:23

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

nblumoe11:12:16

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

nblumoe11:12:49

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….

pesterhazy11:12:30

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

pesterhazy11:12:29

I'm trying right now

pesterhazy11:12:36

how do I install clj?

pesterhazy11:12:43

I'm asking the newb questions here @nblumoe

nblumoe11:12:14

Mac? brew install clojure

pesterhazy11:12:26

ah I tried "brew install clj"

pesterhazy11:12:22

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)

pesterhazy11:12:23

I already had a script called clojure

pesterhazy11:12:35

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

pesterhazy11:12:38

gives you a nice prompt

pesterhazy11:12:34

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

pesterhazy11:12:57

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

cgrand11:12:34

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

pesterhazy11:12:04

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

cgrand11:12:07

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

nblumoe11:12:00

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

nblumoe11:12:53

and blob.clj I am going to build via right?

pesterhazy11:12:42

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

nblumoe11:12:34

Cool thanks. Working from CLI now

baptiste-from-paris11:12:08

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

nblumoe11:12:32

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

cgrand12:12:01

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

nblumoe12:12:49

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

richiardiandrea16:12:38

Quite nice (except the blue ;)) !

cgrand16:12:06

I could even render classes and symbol differently

pesterhazy16:12:57

iterm2 supports hover???

cgrand16:12:45

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

pesterhazy16:12:39

pretty sweet

cgrand16:12:03

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

pesterhazy16:12:45

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

pesterhazy16:12:59

but this looks potentially super useful

cgrand16:12:07

I used none of those because of this

pesterhazy16:12:49

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

pesterhazy16:12:08

is that packed applying the colors?

cgrand16:12:03

it’s the unravel ansi rendering for packed

pesterhazy16:12:04

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

cgrand16:12:24

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

cgrand16:12:40

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

cgrand16:12:27

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

cgrand16:12:03

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

cgrand16:12:32

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

cgrand16:12:11

(forgot to push)

cgrand16:12:50

So the telling code sample is this cond clause:

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

cgrand17:12:43

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