8
votes

I'm using Emacs Live because it seemed nice and saves me a lot of configuration work. Now it worked fine for a few days, but today something apparently broke. Specifically, auto completion broke (I believe it might be an issue with ac-nrepl). Basically, my minibuffer now only shows "Namespace not found.", I don't get real auto-completion anymore (only completion on words that are already in the file). And when I run C-c M-n I get an empty *nREPL error* buffer every time auto completion would usually kick in.

EDIT: This only happens when I start an nrepl-server with nrepl-jack-in. Just connecting to an existing one (e.g. created with lein repl) works fine.

2
if you make a new test project with lein new does it work in that new project? This may help decide if it is a project configuration/structure problem or an emacs problem.Arthur Ulfeldt
Same thing happens with a completely blank project.Cubic
Ask the fine folks on #clojure at irc.freenode.netArthur Ulfeldt
I'd rather not. I do frequent #clojure, but the last time I asked an emacs question there was a short but unnecessary flamewar on whether or not emacs should be used with preconfigured packages. It also feels sort of off topic since it isn't directly related to clojure (except if it was a bug with nrepl itself, which I doubt)Cubic

2 Answers

8
votes

The issue with Namespace not found is that the nrepl doesn't know about the namespace of the current buffer. The issue with nrepl-set-ns (C-c M-n) is that is running in-ns, which doesn't bring the clojure core dependencies.

In both cases, the work around is to either eval just the ns s-expr of the buffer or to load the whole buffer with nrepl-load-current-buffer.

Of course you can modify the nrepl-set-ns to do a ns or add another fn.

0
votes

Looks like adding a possibly empty ns declaration to the buffer:

(ns example ...)

and performing nrepl-set-ns is nrepl's intended usage. It allows working with multiple Clojure buffers, each with its own imports, aliases etc.

I've opted for adding a hook to .clj file creation/opening which automates this work. One still is responsible for refreshing the ns form on modification, though!