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

Honor :init-ns namespace on startup #316

Closed
weissjeffm opened this issue Apr 30, 2013 · 3 comments
Closed

Honor :init-ns namespace on startup #316

weissjeffm opened this issue Apr 30, 2013 · 3 comments

Comments

@weissjeffm
Copy link
Contributor

When I have :repl-options {:init-ns 'my-ns}

and then i run nrepl-jack-in, the starting namespace is still user.

My purpose in using these lein options is to avoid having to type the same thing every time I start a repl. require the namespace, switch to it, etc. Would be nice if it were just "ready" on startup.

Edit: i forgot to mention, the server side does already switch namespaces correctly, it is just not reflected on the emacs side.

@weissjeffm
Copy link
Contributor Author

Here's a little elisp workaround. Theoretically it could go into nrepl.el as-is, but I'm sure there are better ways to accomplish it.

(add-hook 'nrepl-connected-hook 
  (lambda () (nrepl-set-ns (plist-get
                 (nrepl-send-string-sync "(symbol (str *ns*))") :value))))

I did not test this with multiple nrepl sessions, hopefully it would only affect the session being opened.

@jonpither
Copy link
Contributor

Arguably this fix has yielded a bug, in that say you have a project.clj without an :init-ns, but you do have a :main namespace specified, then when you launch a REPL session you'll be put in the :main namespace.

This mirrors nrepl's behavour as "lein repl" will also put you in the namespace specified by main. This then forces you to have an :init-ns, which does then override :main.

I didn't raise a new issue for this because it's arguably an issue with nrepl. I see the nrepl github has issues disabled for some reason.

@bbatsov
Copy link
Member

bbatsov commented Jan 17, 2014

It's Clojure policy. nREPL bugs should be reported to its JIRA issue tracker http://dev.clojure.org/jira/browse/NREPL

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

No branches or pull requests

3 participants