unrepl

discussing specification of an edn-based repl and its implementations.
cgrand 2017-12-05T09:23:08.000182Z

Can your repl do that?

dominicm 2017-12-05T09:45:42.000397Z

I mean, vim can't do that, no matter how hard I try πŸ˜„

cgrand 2017-12-05T09:46:05.000080Z

which part?

dominicm 2017-12-05T09:46:24.000078Z

linewise highlighting only in vim printed output.

cgrand 2017-12-05T09:47:53.000210Z

the twist here is that we have two string representations highlighted differently because they represent different things

1🚘1πŸš–
volrath 2017-12-05T09:56:27.000318Z

really cool πŸ™‚ I actually thought on going for something similar on unrepl.el, but at the end I decided to stick with clojure-mode's font-locking, which is basically based on a syntax table

volrath 2017-12-05T09:56:55.000516Z

super cool to have semantic highlighting

cgrand 2017-12-05T09:57:22.000097Z

could have spared me some hair pulling on a couple of occasions

volrath 2017-12-05T09:58:15.000040Z

but the end result is so pretty πŸ˜„, and the answer to your question will most likely be: "nope, my repl cannot!"

volrath 2017-12-05T10:07:18.000420Z

I wanted to join the party πŸ™‚

pesterhazy 2017-12-05T10:23:01.000052Z

not sure if this is a safe way to replicate lein repl:

java -cp `lein classpath` clojure.main -e "(do (require 'clojure.core.server) (let [srv (clojure.core.server/start-server {:name :repl :port 0 :accept 'clojure.core.server/repl :server-daemon false})] (prn [:jack-in/ready {:port (.getLocalPort srv)}])))"

pesterhazy 2017-12-05T10:23:32.000072Z

For one thing this ignores JVM settings set in project.clj

cgrand 2017-12-05T10:23:42.000084Z

and profiles

pesterhazy 2017-12-05T10:23:52.000458Z

Although maybe that's ok?

cgrand 2017-12-05T10:24:03.000204Z

that can be iterated upon

volrath 2017-12-05T10:24:40.000307Z

may I ask, what's the disadvantage of lein trampoline run -m ...?

pesterhazy 2017-12-05T10:24:45.000215Z

lein trampoline run might be safer

pesterhazy 2017-12-05T10:24:52.000190Z

jinx!

volrath 2017-12-05T10:25:04.000584Z

haha al-most-

pesterhazy 2017-12-05T10:25:33.000138Z

what does CIDER do?

dominicm 2017-12-05T10:25:53.000330Z

lein update-in :plugins conj '[cider-nrepl]' -- repl

cgrand 2017-12-05T10:26:11.000289Z

lein classpath can be cached (based on a hashes) so starting faster than lein

volrath 2017-12-05T10:26:15.000144Z

cider lets you construct a command based on parameters and global options

pesterhazy 2017-12-05T10:26:42.000110Z

not sure we want to do caching at this point (will inevitably lead to problems if not handled carefully)

pesterhazy 2017-12-05T10:27:30.000503Z

how about encapsulating the jack-in logic in a shell script - then we can share the logic between unrepl.el and unravel?

1πŸ‘
volrath 2017-12-05T10:28:24.000291Z

^ wow

pesterhazy 2017-12-05T10:32:11.000008Z

may I ask, why wouldn't it be easy from elisp?

volrath 2017-12-05T10:32:27.000198Z

https://github.com/Unrepl/unrepl.el/commit/99ff8b1e3a2a80cbcf351debf1a0ea7a1583e810 this commit has basically all the autodiscover feature

volrath 2017-12-05T10:32:38.000177Z

I'm not saying it wouldn't be easy

pesterhazy 2017-12-05T10:32:51.000300Z

ah you want to make things configurable?

volrath 2017-12-05T10:32:52.000094Z

just not as practical

volrath 2017-12-05T10:33:46.000092Z

I made them customizable same as cider, you can customize the way you call either boot or lein, as long as you know that a -i <repl initialization code> is going to happen

pesterhazy 2017-12-05T10:33:49.000404Z

another worry is that shell scripts won't work on windows

volrath 2017-12-05T10:34:07.000317Z

what exactly did you want to put into a shell script?

volrath 2017-12-05T10:34:15.000032Z

maybe we're talking different things

pesterhazy 2017-12-05T10:35:07.000380Z

if [[ -e project.clj ]]; then exec lein run ....; elsif [[ -e build.boot ]]; then exec boot socket-server; else clj ...; fi

volrath 2017-12-05T10:38:29.000012Z

right. so the thing is I do the "[[ -e project.clj ]] .." as its own function called unrepl-socket--clojure-project-type and I use it some other places, wouldn't want to split the same behavior into two sources

volrath 2017-12-05T10:38:34.000491Z

plus the configuration thing

volrath 2017-12-05T10:39:27.000229Z

and in my case, it's a bit more than just checking if a certain build tool file exists

volrath 2017-12-05T10:39:46.000518Z

I also have to get to the root of the project, because I can be starting the repl from a subdirectory

pesterhazy 2017-12-05T10:48:07.000461Z

are these things that could be done in a shell script as well?

pesterhazy 2017-12-05T10:49:04.000013Z

reimplementing in elisp is fine of course but I'm thinking it could be nice to have the autosensing code in some kind of module you can test individually

pesterhazy 2017-12-05T10:49:45.000131Z

we should at least standardize the :jack-in/ready message, no?

volrath 2017-12-05T10:51:05.000319Z

of course they can be implemented as shell scripts

volrath 2017-12-05T10:53:06.000014Z

one thing i notice about the jack-in message, when you are starting a boot repl, output can contain a lot more than just the message, it comes with other information and maybe some ansi code gibberish (which i guess could be avoided by cli)

volrath 2017-12-05T10:53:25.000357Z

plus, at least for me, the message always comes in to chunks

volrath 2017-12-05T10:53:46.000365Z

I get "[" and then ":jack-in/ready ...]"

volrath 2017-12-05T10:55:19.000212Z

so I have to buffer the output and check... parseedn gets stuck with the whole output (including gibberish) for some reason I didn't have time to debug, and even if it didn't get stuck the sensible response should be a parse error... so I went with a simple regex "\\[:unrepl\.el/server-ready \\([0-9]+\\)\\]"

volrath 2017-12-05T10:55:43.000131Z

(I simplified the message to [:unrepl.el/server-ready <port>])

volrath 2017-12-05T10:58:56.000406Z

having said that, I do agree it would be nice to have a standalone module for this and be able to constantly test it

cgrand 2017-12-05T11:00:33.000227Z

gibberish prelude can happen with lein trampoline run too

cgrand 2017-12-05T11:04:12.000358Z

to avoid chunking (println (pr-str msg))

pesterhazy 2017-12-05T11:06:29.000013Z

first pass at this: https://github.com/Unrepl/unravel/pull/54/files

pesterhazy 2017-12-05T11:07:42.000317Z

I'd just regex through the output line by line until I find something like [:jack-in/ready.* and then read from there

cgrand 2017-12-05T11:09:06.000287Z

@pesterhazy (println (pr-str msg)) is about more than chunking, when you are on a bad day you may have spurious prints interleaved with your message when you do (prn msg)

volrath 2017-12-05T11:09:20.000084Z

that was my first approach, but it failed because of the possible extra stuff that could come after the mesage... with @cgrand's println trick this can be solved

pesterhazy 2017-12-05T11:10:16.000230Z

Clojure's read-string reads the first complete form and then stops - does your edn.el work differently?

pesterhazy 2017-12-05T11:10:34.000349Z

good albeit slightly obscure point @cgrand πŸ™‚

volrath 2017-12-05T11:11:16.000066Z

good question, it seems that it does so.. at some point, it gets stucked

cgrand 2017-12-05T11:11:57.000255Z

$ lein trampoline run -m clojure.main -e β€˜(prn :oh-noes)’
objc[9868]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bin/java (0x108d484c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x10a4d94e0). One of the two will be used. Which one is undefined.
Initializing NoDisassemble Transformer
:oh-noes

cgrand 2017-12-05T11:12:53.000379Z

can’t your grep|sed the output of exec right in the shell script?

volrath 2017-12-05T11:14:25.000010Z

that's what I'm doing already

pesterhazy 2017-12-05T11:15:26.000048Z

switched to your println suggestion @cgrand

cgrand 2017-12-05T11:15:36.000152Z

yeah I saw

volrath 2017-12-05T11:15:39.000234Z

I just take the relevant part of the output... the part after the message was what was messing up with parseedn, but now with the println thing I'm good

pesterhazy 2017-12-05T11:16:51.000025Z

maybe a good idea to add a "\n" at the start as well so we're sure we have a line to ourselves?

2πŸ‘
pesterhazy 2017-12-05T11:22:22.000327Z

I think it could still happen theoretically that another thread writes to stdout while we're writing our string but it seems unlikely given that the string length is less than reasonable buffer sizes

cgrand 2017-12-05T11:29:27.000023Z

Yeah, that’s sad that https://github.com/dmlloyd/openjdk/blob/jdk10/master/src/java.base/share/classes/java/io/OutputStream.java#L106 is not synchronized

cgrand 2017-12-05T11:29:58.000157Z

luckily most descendants do synchronize (eg BufferedOutputStream)

cgrand 2017-12-05T14:00:55.000442Z

Hold my 🍺

cgrand 2017-12-05T20:08:20.000134Z

Well it will have to wait next week