planck

Planck ClojureScript REPL
dpsutton 2017-11-19T21:30:13.000130Z

hi @mfikes I see that planck returns a #js array of completions. inf-clojure just blindly calls read in elisp on this structure which fails due to the #js reader. Can you tell me why this is returned as a javascript array and not a clj immutable vector? Just trying to figure out where the correct bug report should go

mfikes 2017-11-19T21:48:58.000050Z

@dpsutton Which API are you referring to?

dpsutton 2017-11-19T21:49:06.000062Z

get-completions

dpsutton 2017-11-19T21:49:19.000013Z

but i see that you pass that directly into the corejavascript stuff

mfikes 2017-11-19T21:49:23.000125Z

Oh, that's not a public API

dpsutton 2017-11-19T21:49:36.000026Z

(defn- ^:export get-completions

dpsutton 2017-11-19T21:49:53.000073Z

get completions is exposed in repl. It is how inf-clojure asks for completions

mfikes 2017-11-19T21:50:05.000134Z

See the minus sign after the defn?

dpsutton 2017-11-19T21:50:15.000078Z

ah yes i do. i missed that. sorry

mfikes 2017-11-19T21:50:33.000062Z

That API actually just changed recently, fairly drastically, so if something is calling it, it may break

dpsutton 2017-11-19T21:51:02.000068Z

yeah it looks like inf-clojure was relying on that coming back as a list

mfikes 2017-11-19T21:51:20.000095Z

There is one public API, planck.repl/get-arglists that was added for inf-clojure (and IIRC, Lumo has the same API with same semantics)

mfikes 2017-11-19T21:51:48.000084Z

Perhaps another public API could be added for completions

dpsutton 2017-11-19T21:52:03.000054Z

would just suggest calling dir and doing it client side?

dpsutton 2017-11-19T21:52:19.000091Z

as it stands get-completions is fine if i strip off the #js and convert to a list in elisp

dpsutton 2017-11-19T21:52:46.000054Z

if that is intended to be stable that or something very similar that is meant for consumption would be fine

dpsutton 2017-11-19T21:53:10.000006Z

don't mean to hog your time if you are enjoying your sunday

mfikes 2017-11-19T21:53:33.000103Z

But, it really has its own semantics, tied to the way it works with the Linenoise buffer. An example call might be (planck.repl/get-completions "(cljs.core/ma")

mfikes 2017-11-19T21:54:17.000135Z

No, it wasn't intended to be stable. It internally changed what it was returning with https://github.com/mfikes/planck/commit/863b7b14383aa40427923f8bb5d11dc88a501a6f

mfikes 2017-11-19T21:55:02.000029Z

I suppose if you build completions using dir then the result is fairly portable across REPLs.

mfikes 2017-11-19T21:55:37.000082Z

Planck's completions include more than what dir gives though (so does Lumo).

mfikes 2017-11-19T21:55:49.000046Z

One example is namespaces. Another is spec keywords.

mfikes 2017-11-19T21:56:55.000112Z

But you will run into trouble if you assume it is doing what you might thing it is doing.

mfikes 2017-11-19T21:57:22.000028Z

For example, compare (planck.repl/get-completions "fo") vs. (planck.repl/get-completions "for")

mfikes 2017-11-19T21:57:54.000105Z

The first shows that you can complete "up to" for, while the second shows that you can complete with either for or force, which isn't included in the first result.

mfikes 2017-11-19T21:58:06.000034Z

(This is just an example of how even the semantics are internal.)

dpsutton 2017-11-19T21:58:56.000115Z

ah i understand your point about linenoise now