Fork me on GitHub
#babashka
<
2020-10-23
>
borkdude14:10:57

A new CLI: https://github.com/borkdude/puget-cli Can be used to colorize / pprint EDN.

😎 24
3
solf21:10:35

I'm having issues showing the documentation of a variable using CIDER (with C-c C-d C-d or cider-doc). It doesn't use the symbol at point, and even if I type it, it returns an error. Example trace with map:

Debugger entered--Lisp error: (wrong-type-argument stringp ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]))
  string-match("\n" ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]) 0)
  split-string(([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]) "\n")
  cider-docview-render-info(#<buffer *cider-doc*> (dict "ns" "clojure.core" "name" "map" "built-in" t "arglists" "([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 &..." "doc" "Returns a lazy sequence consisting of the result o..." "file" "" "arglists-str" ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])))
  cider-docview-render(#<buffer *cider-doc*> "map" (dict "ns" "clojure.core" "name" "map" "built-in" t "arglists" "([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 &..." "doc" "Returns a lazy sequence consisting of the result o..." "file" "" "arglists-str" ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])))
  cider-create-doc-buffer("map")
  cider-doc-lookup("map")
  cider-try-symbol-at-point("Doc for" cider-doc-lookup)
  cider-doc(nil)
  funcall-interactively(cider-doc nil)
  call-interactively(cider-doc nil nil)
  command-execute(cider-doc)

borkdude21:10:22

Does cider-doc require some non-standard nREPL middleware?

borkdude21:10:49

it would be helpful if you could post the output from the nrepl messages buffer

solf21:10:10

No idea. I'm almost positive cider-doc worked before. I'll check the result from the nrepl buffer

borkdude21:10:42

You could try using an older release to double check if it worked before.

solf21:10:16

I'll try that, at the moment using:

`--> bb --version
babashka v0.2.3
CIDER 1.0.0snapshot (package: 20201020.1058)

solf21:10:44

(I just updated CIDER to see if it fixed the error, don't remember how old was my previous version)

solf21:10:06

I haven't checked older versions on the nrepl buffer yet, but looking at the error stacktrace I can see that the result from nrepl contains both an arglists and an arglists-str

solf21:10:23

however neither is a string

solf21:10:41

And then CIDER is splitting arglists-str thinking it's a string, which throws the error

solf21:10:51

No there's no specific nrepl op for doc

solf21:10:10

instead eval is used:

(-->
  id         "22"
  op         "eval"
  session    "31de0313-76e6-4bf8-89bf-22e284741af8"
  time-stamp "2020-10-23 23:55:22.795699101"
  code       "
(do
  (require ')
  (require 'clojure.walk)

  (if-let [var (resolve 'map)]
    (let [info (meta var)]
      (-> info
          (update :ns str)
          (update :name str)
          (update :file (comp str ))
          (cond-> (:macro info) (update :macro str))
          (cond-> (:special-form info) (update :special-form str))
          (cond-> (:protocol info) (update :protocol str))
          (cond-> (:arglists info) (update :arglists str))
          (assoc :arglists-str (:arglists info))
          (clojure.walk/stringify-keys)))))
"
)
(<--
  id         "22"
  session    "31de0313-76e6-4bf8-89bf-22e284741af8"
  time-stamp "2020-10-23 23:55:22.805649515"
  ns         "hello"
  value      "{\"ns\" \"clojure.core\", \"name\" \"map\", \"built-in\" true, \"arglists\" \"([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])\", \"doc\" \"Returns a lazy sequence consisting of the result of applying f to\\n  the set of first items of each coll, followed by applying f to the\\n  set of second items in each coll, until any one of the colls is\\n  exhausted.  Any remaining items in other colls are ignored. Function\\n  f should accept number-of-colls arguments. Returns a transducer when\\n  no collection is provided.\", \"file\" \"\", \"arglists-str\" ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])}"
)

solf21:10:15

.... sorry, this is my bad, it comes from my config customization

solf21:10:48

I completely forgot, but I added support for cider-doc myself a few months ago, I guess the code is out of date now

solf21:10:59

the clj function in the nrepl eval comes from my config

solf22:10:57

Hey no, it doesn't! https://github.com/clojure-emacs/cider/blob/1be3b89c00d9fe6d2b69e5b719d168e22d333a25/cider-client.el#L422 This is late for me, so I'll continue to investigate this tomorrow and will create an issue in babashka/nrepl then

solf22:10:22

Nevermind, found it, and it's a bug in cider, I'll file a report there. The eval code is a fallback when there's no nrepl support for the op info, which is why it happens on babashka. Commit in question: https://github.com/clojure-emacs/cider/commit/1be3b89c00d9fe6d2b69e5b719d168e22d333a25

borkdude22:10:57

That expression does seem to work when evaluated as a normal bb script

borkdude22:10:16

E.g. for map I get:

{"ns" "clojure.core", "name" "map", "built-in" true, "arglists" "([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])", "doc" "Returns a lazy sequence consisting of the result of applying f to\n  the set of first items of each coll, followed by applying f to the\n  set of second items in each coll, until any one of the colls is\n  exhausted.  Any remaining items in other colls are ignored. Function\n  f should accept number-of-colls arguments. Returns a transducer when\n  no collection is provided.", "file" "", "arglists-str" ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])}
`

solf22:10:37

the eval works, but the commit introduced a bug: arglists-str is not a string anymore

solf22:10:52

so emacs throws when trying to split it by \n

borkdude22:10:35

Getting late here too, I think we're in the same timezone

solf22:10:57

now yes! I did a tad of work on babashka/nrepl when I was in Singapore, but now I'm in france to visit my family

solf22:10:40

I care about having babashka work well with cider ahah

solf22:10:43

good night then

borkdude22:10:08

same to you :)