abo-abo / lispy

Short and sweet LISP editing
http://oremacs.com/lispy/
1.2k stars 132 forks source link

[bug] `lispy-describe-line` currently returns no result in clojure-mode #547

Open cstby opened 3 years ago

cstby commented 3 years ago

System Info

Mac OS Emacs 27.1 Lispy 20200818.1151 Cider 20200930.1242 Clojure-mode: 20201001.1449

Expected result

Executing lispy-describe-inline on a clojure.core function will display documentation inline.

Actual result

Execting lispy-describe-inline on a clojure.core function doesn't do anything at all. (No messaage, no error, no documentaton.)

Steps to reproduce

adrech commented 3 years ago

When stepping through lispy--docstring with edebug, it seems that lispy--clojure-resolve returns a propertized string, which leads to an error when [something in] lispy--eval-clojure-cider calls the repl:

#("Syntax error compiling at (*cider-repl ...localhost:33715(clj)*:1:97).\nUnable to resolve symbol: face in this context\n"

;; lispy/lispy-inline.el 
;; Lines 257-264
;; (defun lispy--docstring (sym) ...
(let ((rsymbol (lispy--clojure-resolve sym)))
  (string-trim-left
   (replace-regexp-in-string
    "^\\(?:-+\n\\|\n*.*$.*@.*\n*\\)" ""
    (cond ((stringp rsymbol)
           (read
            (lispy--eval-clojure-cider
             (format "(with-out-str (clojure.repl/doc %s))" rsymbol))))

Relevant edebug messages:

sym 
=>
"ranged-rand"

(lispy--clojure-resolve sym) 
=>
#("ripe-clj.core-test/ranged-rand" 0 18 (face font-lock-type-face cider-locals nil help-echo
cider--help-echo) 18 29 (cider-locals nil help-echo cider--help-echo) 29 30 (font-lock-multiline t
cider-locals nil help-echo cider--help-echo))

(format "(with-out-str (clojure.repl/doc %s))" rsymbol)
=>
Result: #("(with-out-str (clojure.repl/doc ripe-clj.core-test/ranged-rand))" 32 50 (help-echo
cider--help-echo cider-locals nil face font-lock-type-face) 50 61 (help-echo cider--help-echo
cider-locals nil) 61 62 (help-echo cider--help-echo cider-locals nil font-lock-multiline t))

(lispy--eval-clojure-cider ...)
=>
Result: #("Syntax error compiling at (*cider-repl ...:localhost:33715(clj)*:1:97).\nUnable to
resolve symbol: face in this context\n" 0 26 (cider-locals nil help-echo cider--help-echo) 26 27
(face (rainbow-delimiters-depth-1-face) cider-locals nil help-echo cider--help-echo) 27 39
(cider-locals nil help-echo cider--help-echo) 39 42 (face font-lock-type-face cider-locals nil
help-echo cider--help-echo) 42 51 (cider-locals nil help-echo cider--help-echo) 51 67 (face
clojure-keyword-face cider-locals nil help-echo cider--help-echo) 67 68 (face
(rainbow-delimiters-depth-2-face) cider-locals nil help-echo cider--help-echo) 68 71 (cider-locals
nil help-echo cider--help-echo) 71 72 (face (rainbow-delimiters-depth-2-face) cider-locals nil
help-echo cider--help-echo) 72 78 (cider-locals nil help-echo cider--help-echo) 78 79 (face
(rainbow-delimiters-depth-1-face) cider-locals nil help-echo cider--help-echo) 79 128 (cider-locals
nil help-echo cider--help-echo))

Cider 1.1.0snapshot Emacs 27.1 lispy @ 38a7df4cbb16cfe3d62dc8ea98b50e2d9a572e58