Giter VIP home page Giter VIP logo

Comments (12)

purcell avatar purcell commented on May 26, 2024

That's a known error upstream in nrepl (on the Clojure side). It will be fixed in time, but not by ac-nrepl.

from ac-nrepl.

tbatchelli avatar tbatchelli commented on May 26, 2024

it looks like this is actually an issue in clojure itself, as (doc clojure.set) returns the exception above, see http://dev.clojure.org/jira/browse/CLJ-902 which seems to be fixed for clojure 1.5

One option would be to filter out exceptions returned by doc and present nil (or ERROR) to the user.

from ac-nrepl.

purcell avatar purcell commented on May 26, 2024

That's not so easy, because the error is a compiler error, and intercepting errors thrown at the nrepl evaluation level is tricky.

Another option might be to evaluate code like that used by swank-clojure rather than relying on the possibly-broken clojure.repl/doc fn:

https://github.com/technomancy/swank-clojure/blob/master/src/swank/commands/basic.clj#L231

from ac-nrepl.

wrn avatar wrn commented on May 26, 2024

I am puzzled why if I do this in a regular "lein repl" shell:
(complete.core/completions "clojure.set/" ns)
everything works fine. I can see all the completions.

But if I do the same in an Emacs nrepl buffer, I got the exception as described in this thread.

I am using lein2 preview 10, and nrepl.el 0.1.4 preview

Can someone explain? Thanks.

from ac-nrepl.

kingtim avatar kingtim commented on May 26, 2024

@wrn To make a short story long, the reason why it works in REPL-y and not in nrepl.el is that the command line version of REPL-y installs a newer version of the function resolve-class in clojure-complete.

You can see this here:
https://github.com/trptcolin/reply/blob/master/src/clj/reply/initialization.clj#L129

We don't do this when launching the nrepl server.

This particular bug has been fixed in clojure-complete (see ninjudd/clojure-complete#3 ).
So getting it fixed is a matter of getting a new version of clojure-complete released and included in lein repl.

from ac-nrepl.

wrn avatar wrn commented on May 26, 2024

Thanks. That explains it. I just re-defined the resolve-class in namespace complete.core and completions works in nrepl buffer now. So I guess I can use this as a temporary work around until the new version is out.

from ac-nrepl.

daviesian avatar daviesian commented on May 26, 2024

Hi folks,

Even when redefining resolve-class in namespace complete.core, I still get the above-mentioned ClassNotFoundException from nrepl in emacs. It's actually coming from the call to clojure.repl/doc on line 82 of ac-nrepl.el:

https://github.com/purcell/ac-nrepl/blob/master/ac-nrepl.el#L82

Redefining ac-nrepl-documentation as

(defun ac-nrepl-documentation (symbol)
  "Return documentation for the given SYMBOL, if available."
  (substring-no-properties
   (replace-regexp-in-string
    "\r" ""
    (replace-regexp-in-string
     "^\\(  \\|-------------------------\r?\n\\)" ""
     (plist-get (nrepl-send-string-sync
                 (format "(try (eval '(clojure.repl/doc %s)) (catch Exception e (println \"Doc threw an error. Namespace?\")))" symbol)
                 (nrepl-current-ns))
                :stdout)))))

Fixes the problem. A similar issue exists in nrepl.el (https://github.com/kingtim/nrepl.el/blob/master/nrepl.el#L1486).

Does no-one else see this problem? I'll happily create pull requests if it would be useful.

Cheers,
Ian

from ac-nrepl.

kingtim avatar kingtim commented on May 26, 2024

I believe the issue here is possibly the use (nrepl-current-ns). I believe this should be nrepl-buffer-ns.
Which version of nrepl.el are you using?
Is this occurring while editing a clojure buffer, or in the repl buffer?
If a clojure buffer, have you loaded the file using C-c C-k?

from ac-nrepl.

purcell avatar purcell commented on May 26, 2024

Yes, nrepl-buffer-ns sounds right. Not sure where the (nrepl-current-ns) came from in the first place, but it's trivial for me to change it if it's obviously wrong...

from ac-nrepl.

daviesian avatar daviesian commented on May 26, 2024

I'm using the *nrepl* buffer. Whether or not there's an issue with (nrepl-current-ns), it is definitely the case that (clojure.repl/doc clojure.set) will always throw a ClassNotFoundException, which needs to be caught (at least until we all move to clojure 1.5, where the doc macro has been fixed).

I'm using the latest nrepl.el from the master branch.

I'm sure I'm missing something, I appreciate you folks taking the time to help!

Cheers,
Ian

from ac-nrepl.

kingtim avatar kingtim commented on May 26, 2024

I see.
Yes, it would appear we are going to have to wrap that doc call in a try catch.

from ac-nrepl.

purcell avatar purcell commented on May 26, 2024

Thanks guys -- I've added the fix from @daviesian and changed nrepl-current-ns to nrepl-buffer-ns. There's a new package (0.7) up on Marmalade.

from ac-nrepl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.