Fork me on GitHub
#unrepl
<
2017-06-16
>
cgrand07:06:32

@volrath yes the documentation for :prompt is out of sync

cgrand08:06:14

I was looking at compliment (https://github.com/alexander-yakushev/compliment). Some thoughts: • completion if a half static/half dynamic task, does the in-process tooling should take care of the static part? • a separate concern is vim editors with crippled scripting where there’s a push to offload brains to the tooled process (they need a proper isolation)

cgrand08:06:20

So basically can we start with just a :completion action that takes a string (or a tagged-lit regex) and returns a list of matches? And without specifying much (in the string case) how the match is done (strict prefix, fuzzy, even fuzzier)

cgrand08:06:27

(and an unrepl source for compliment could be added, allowing compliment to be used... on the editor side)

cgrand08:06:56

I don’t see myself commiting fine-grained actions in unrepl.

volrath08:06:16

sounds good. I also think that a :completion action could be generic enough to accommodate for completion libraries like compliment. One thing though, maybe I didn't understand well what you meant by a "tagged-lit regex", but I'm guessing that the action should take at least two parameters: the whole string/form the user's been typing and a cursor position, so that completion libraries can take advantage of context. in case of compliment: https://github.com/alexander-yakushev/compliment/wiki/Context

plexus08:06:06

@thheller I'm sorry you had to deal with that print.cljc. It basically came about when I asked "what's the next thing we need to make a cljs unrepl happen", and someone said "port print.clj", so I fired up Lumo in inf-clojure and start going through it top to bottom, making sure I could evaluate each form without errors. After that I wasn't sure how to continue as it seemed there were some other pieces missing (I guess that would be cljs-js-repl which I wasn't aware of at the time).

cgrand09:06:00

plexus: I put comments on your commit but it’s more for me than for you: things to keep in mind when I merge some of your changes.

cgrand08:06:09

I’m the someone 🙂

plexus08:06:45

I'll be working more on unrepl.el this weekend. Current status there is that I've started writing a Clojure/EDN parser from scratch out of frustration with edn.el. This will likely become its own Emacs package as it seems some other tooling could benefit from a good parser as well. But so there's a bit of yak shaving to be done at the moment. After that I want to implement proper tracking of eval/echo, which should make it possible to get proper in-buffer evaluation with results in an overlay, as well as other tooling-related evaluation that does something else with the result than show it in the repl.

plexus08:06:09

@cgrand I think it was someone else repeating what you had said previously 🙂

cgrand08:06:41

@plexus ok fine, blame the messenger!

plexus08:06:18

I don't blame anyone, I think it's all worthwhile, just want to make sure people don't expect too much from print.cljc

cgrand08:06:21

@volrath it’s not what I have on my mind (for compliment, I was thinking of just providing enough to implement a new source, and have compliement run in the editor, not in the “server” process) So I was thinking “small string” while you are thinking “whole form + cursor position”, it’s coarse grained too and I didn’t consider it. Interesting.

plexus08:06:18

the clojure/edn parser will be a hand written shift-reduce parser, which will be able to give a partial syntax tree in case of parse errors, and which can be used to either parse EDN to elisp lists/vectors/hashes, or Clojure to a tools.analyzer style AST. It uses an internal stack instead of using recursion, which means it doesn't overflow the elisp stack (which edn.el is prone to do)

plexus08:06:15

Also I'll be speaking (remotely) about unrepl/unrepl.el at the London Emacs Meetup on the 26th. There will be video afterwards. I'm in charge of the recording and editing though so it might take a while 🙂

cgrand08:06:21

the elisp stack is rather shallow? Anyway sounds promising

plexus08:06:51

yeah it's rather shallow, also edn.el is based on the PEG parser generator library, which seems to use many more stack frames than necessary

thheller08:06:02

@plexus no worries .. I’m rather surprised that this actually works in lumo since it should be using the same tools.reader I do?

plexus08:06:40

No idea to be honest, I would have to dive in again.

cgrand09:06:20

If the selection is wrapped in a do before evaluation it may explain the behaviour

pesterhazy09:06:26

@cgrand, I agree about starting with a simple approach

cgrand09:06:03

yes but which one?

pesterhazy09:06:57

hehe I'm typing slowly today

pesterhazy09:06:39

one question could be how that falls short

pesterhazy09:06:43

on the completer side, it only does non-fuzzy prefix-completion; on the "gathering candidates" side, it looks at namespaces and local or qualified vars

pesterhazy09:06:05

how could this be improved?

pesterhazy09:06:12

- moving into unrepl source code

pesterhazy09:06:04

- more candidate gathering sources (keywords? method names?)

pesterhazy09:06:56

- better completion algorithms (allow for typos, allow for missing characters ("repfir" will match "replace-first"))

pesterhazy09:06:20

- more generality

pesterhazy09:06:55

- cljs support (but that would require cljs support in unrepl first)

pesterhazy09:06:03

- better sorting of matches

pesterhazy09:06:27

- adding annotations to matches (fn signature, first line of docstring)

cgrand09:06:49

“gathering candidates side” is in CLJS?

cgrand10:06:33

so you agree with me that that part should not be part of unrepl, right?

pesterhazy11:06:37

can you explain a bit more what you're suggesting?

cgrand11:06:41

Turns out there are rough edges to the repl experience in bootstrap

pesterhazy11:06:59

i want to be sure what I'm agreeing to

cgrand11:06:03

@pesterhazy unrepl only exposes stuff that the client can’t do, so only completion of dynamic things (namespaces, vars, maybe classes)

cgrand11:06:32

keywords, locals etc are done by the client

pesterhazy11:06:40

sounds right to me

pesterhazy11:06:45

just to be clear that I'm understanding, the client would gather keywords by e.g. scanning the file for #":[a-z-]*"

pesterhazy11:06:22

the client cannot do that effectively with namespaces because it needs to inspect the dynamic runtime environment

pesterhazy11:06:38

we don't want to extend unrepl's scope too much, so our principle would be to expose the data the client needs and cannot get by itself, but nothing more

pesterhazy11:06:36

so one thing to add would be a completion function. E.g. (unrepl/candidates-by-prefix "fil") would return [{:symbol 'filter :docstring "..."} ,,,]?

thheller12:06:42

wth? does unrepl suddenly do completions?

cgrand13:06:00

@thheller 🙂 tryiing to find a tradeoff between “do nothing” and “do just enough for the client to be independent” (again, commands are optional and they are an openset etc.)

thheller13:06:44

yeah, talked with Paulus. Misunderstanding on my part

dominicm13:06:06

@thheller curious as to what made you feel okay with it.

thheller13:06:40

not my decision to make … I’ll be building the language server and expose RPC-ish commands like clj/eval and cljs/eval

thheller13:06:56

those will throw if you try to (read) as all this is not going to be a REPL

thheller13:06:11

strictly for tools not humans (not actually strict RPC, message based with async notifications and RPC)

thheller13:06:10

I have a simple socket REPL for humans that exposes enough information to make autocomplete and stuff work

thheller13:06:40

but the autocomplete will then go over the RPC thing, not the REPL

thheller13:06:02

very different goal than unrepl

thheller13:06:39

trying to figure out how the upgrade works with CLJS makes my head hurt too much

cgrand14:06:46

One could also imagine advertising the language server endpoint in unrepl hello.

thheller15:06:18

yeah the thing I just can’t figure out is how the upgrade can work for CLJS without actually controlling how its started

thheller15:06:55

the send a blob approach just doesn’t work since eval is in JS

cgrand15:06:44

The loop on the js side has to be made upgradable

thheller15:06:55

but there is no loop on the JS side

pesterhazy17:06:43

au contraire! Javascript is loops all the way down

cgrand17:06:19

Lambda the ultimate GOTO

cgrand17:06:28

The message queue from which the strings (js code) to eval are received has to be public and have a .pushListener method and maintains a stack of listeners, only the top one is active.