Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibilities with Clojurescript #150

Open
austinhaas opened this issue Jul 7, 2018 · 4 comments
Open

Incompatibilities with Clojurescript #150

austinhaas opened this issue Jul 7, 2018 · 4 comments

Comments

@austinhaas
Copy link
Contributor

austinhaas commented Jul 7, 2018

inf-clojure included non-portable Clojure code, and it automatically enables an eldoc feature which triggers the non-portable code in a Clojurescript REPL.

https://github.com/clojure-emacs/inf-clojure/blob/master/inf-clojure.el#L859

(defcustom inf-clojure-arglists-form
  "(try
     (:arglists
      (clojure.core/meta
       (clojure.core/resolve
        (clojure.core/read-string \"%s\"))))
     (catch Throwable t nil))"
  "Form to query inferior Clojure for a function's arglists."
  :type 'string
  :safe #'stringp
  :package-version '(inf-clojure . "2.0.0"))

Throwable isn't available in clojurescript. Additionally, when called from clojurescript, this code will throw an error stating that the argument to resolve must be a quoted symbol.

WARNING: Use of undeclared Var cljs.user/Throwable at line 6 <cljs repl>
clojure.lang.ExceptionInfo: Assert failed: Argument to resolve must be a quoted symbol
(core/and (seq? quoted-sym) (= (quote quote) (first quoted-sym))) at line 4 <cljs repl> {:file "<cljs repl>", :line 4, :column 2, :root-source-info {:source-type :fragment, :source-form (try (:arglists (clojure.core/meta (clojure.core/resolve (clojure.core/read-string "ClojureScript")))) (catch Throwable t nil))}, :tag :cljs/analysis-error}

In spite of these issues, I don't think these "eldoc" helper functions should be called if the user doesn't have eldoc-mode enabled. I've resolved the issue by commenting out the call to inf-clojure-eldoc-setup
on Line 182: https://github.com/clojure-emacs/inf-clojure/blob/master/inf-clojure.el#L182

@arichiardi
Copy link
Contributor

arichiardi commented Jul 8, 2018

Thanks for reporting, we should definitely have a cljs REPL type. The one you see above is for Clojure only IIRC.

You can see there are customizations for Planck and Lumo in the code but not for "generic" cljs... probably nobody has ever used it - not even myself with it. I used to use Lumo quite extensively though.

@austinhaas
Copy link
Contributor Author

austinhaas commented Jul 8, 2018

I started adding the CLJS REPL type: https://github.com/austinhaas/inf-clojure/blob/cljs/inf-clojure.el

The eldoc stuff seems to work ok (I've barely tested), but it seems kinda slow. Emacs will hang for a fraction of a second after I move the cursor to a new expression. (Edit: The slowness was due to the browser not having focus).

I also see a problem, both with this new CLJS stuff and with CLJ, where multiple prompts are printed. This may be related to the eldoc stuff, but I'm not sure. For instance, if I move the cursor to a function and for whatever reason the arguments can't be printed, a new prompt might be printed. Sometimes the prompts appear randomly. (I also don't understand why some output goes to the REPL and some goes to the JS console.)

I haven't updated ":package-version" for the new custom functions. I assume that would be set to the next version number.

I'm not sure what to do with inf-clojure-completion-form-cljs: https://github.com/austinhaas/inf-clojure/blob/cljs/inf-clojure.el#L974 The clojure version appears to use a library named clojure.complete. It is assumed that the user is including this library in their project?

@bbatsov
Copy link
Member

bbatsov commented Jul 8, 2018

Btw, there's some historical context here #6

I also see a problem, both with this new CLJS stuff and with CLJ, where multiple prompts are printed. This may be related to the eldoc stuff, but I'm not sure. For instance, if I move the cursor to a function and for whatever reason the arguments can't be printed, a new prompt might be printed. Sometimes the prompts appear randomly. (I also don't understand why some output goes to the REPL and some goes to the JS console.)

Multiple prompts get printed when you eval something with newlines in it. Haven't look at the code in a long time, but back in the day my solution was to simply create long single-line forms for everything.

I haven't updated ":package-version" for the new custom functions. I assume that would be set to the next version number.

Yes.

I'm not sure what to do with inf-clojure-completion-form-cljs: https://github.com/austinhaas/inf-clojure/blob/cljs/inf-clojure.el#L974 The clojure version appears to use a library named clojure.complete. It is assumed that the user is including this library in their project?

It's a lein dependency (by virtue of reply being a lein dep), which means a lot of people have it by default. The other should add this manually for the completion to work. I think at some point @arichiardi also added support for compliment. The cljs completion support should be implemented in terms of https://github.com/clojure-emacs/cljs-tooling

@arichiardi
Copy link
Contributor

arichiardi commented Jul 9, 2018

Confirm that the cljs-tooling lib solves the completion problem in cljs and maybe after the ongoing PR will be also what lumo uses.

Away from the keyboard for our two weeks but when I come back I can validate / help this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants