Fork me on GitHub
#planck
<
2017-11-19
>
dpsutton21:11:13

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

mfikes21:11:58

@dpsutton Which API are you referring to?

dpsutton21:11:06

get-completions

dpsutton21:11:19

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

mfikes21:11:23

Oh, that's not a public API

dpsutton21:11:36

(defn- ^:export get-completions

dpsutton21:11:53

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

mfikes21:11:05

See the minus sign after the defn?

dpsutton21:11:15

ah yes i do. i missed that. sorry

mfikes21:11:33

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

dpsutton21:11:02

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

mfikes21:11:20

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)

mfikes21:11:48

Perhaps another public API could be added for completions

dpsutton21:11:03

would just suggest calling dir and doing it client side?

dpsutton21:11:19

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

dpsutton21:11:46

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

dpsutton21:11:10

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

mfikes21:11:33

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")

mfikes21:11:17

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

mfikes21:11:02

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

mfikes21:11:37

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

mfikes21:11:49

One example is namespaces. Another is spec keywords.

mfikes21:11:55

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

mfikes21:11:22

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

mfikes21:11:54

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.

mfikes21:11:06

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

dpsutton21:11:56

ah i understand your point about linenoise now