Closed kencausey closed 11 years ago
Apologies for the confusion. That section of the README is from a recent pull request and doesn't seem quite right to me. I think in general you want to have paredit-mode
to be associated with clojure-mode
, so it is enabled whether or not you are connected to nrepl.
I believe if you are using emacs starter kit, paredit should automatically be enabled for clojure-mode
buffers so this should be unnecessary and I will get the README adjusted accordingly.
When you do M-x nrepl-jack-in
, nrepl.el should automatically turn on nrepl-interaction-mode
for all clojure-mode
and clojurescript-mode
buffers, so I am a little confused as to why this isn't happening?
Can you tell me what value you have for the nrepl-connected-hook
by doing M-: nrepl-connected-hook
?
I apologize if I haven't been clear. Paredit is indeed enabled when I open a .clj buffer along with clojure-mode irrespective of whether or not I have linked nrepl-interaction-mode to paredit-mode.
If my init.el does NOT contain (add-hook 'nrepl-interaction-mode 'paredit-mode) and I open a .clj then alt-x nrepl-jack-in, once I get the message that nrepl has started and I have a nrepl buffer, the only modes active on the .clj buffer are Clojure Paredit and Fill, the same as before I ran nrepl-jack-in.
But if I add (add-hook 'nrepl-interaction-mode 'paredit-mode) back into my init.el, restart emacs, and repeat then the modes for the buffer are Clojure nREPL Paredit and Fill, as expected.
nrepl-connected-hook has the value: (ac-nrepl-refresh-class-cache nrepl-enable-on-existing-clojure-buffers). Hmm, should some blame be directed at ac-nrepl? I'll be the first to admit my init.el may be a bit of a mess as I added a number of packages out of curiosity and possibly in ignorance. Is there a conflict here?
It may be related to ac-nrepl. Try setting debug-on-error (i.e. (setq debug-on-error t)
) and then attempt to M-x nrepl-jack-in
and lets see if any errors pop up.
I added
(setq debug-on-error t)
to the top of my ~/.emacs/init.el, commented out
(add-hook 'nrepl-interaction-mode 'paredit-mode)
restarted emacs and tried nrepl-jack-in and there were no errors or debug stacktraces and no nREPL mode.
@kingtim @kencausey I've made a horrible mistake (for which I'm very sorry). I actually meant to write:
(add-hook 'nrepl-mode 'paredit-mode) ;; the idea is to get paredit in the REPL buffer
I'll prepare a PR to update the README.
PR is away #166 (ironically in my country this is the national phone number of the police :-) ).
Thanks to @kingtim for chatting with me on IRC to try to figure this issue out the other day. The problem certainly seems to be related to ac-nrepl and the fact that ac-nrepl.el is loaded before nrepl.el and the order of the hook variable makes a difference although it should not (as far as I can tell). For now I can work around this simply by adding
(setq nrepl-connected-hook (reverse nrepl-connected-hook))
to my init.el so that 'nrepl-enable-on-existing-clojure-buffers is at the head of the list. After doing so everything, including ac-nrepl, seems to be fine. A hack admittedly, but enough to get by on until a proper fix is ready.
And of course note the correction to the add-hook line above from @bbsatov if you saw the readme when it was incorrect.
@kencausey Please consider closing this ticket and opening another one regarding the ac-nrepl
problem, since the ticket's name will probably confuse some people.
I am going to go ahead and close this. If you have other problems please open a new issue.
I had this problem too, quite maddening to track down but the suggested workaround works for me:
(setq nrepl-connected-hook (reverse nrepl-connected-hook))
Gonna open a ticket with ac-nepl about this
Thanks, I hope someone on that side can produce some light on this issue.
I'm running a local build of emacs from git fetched and built on Nov 19, 2012. On the same day I checked for updates from melpa and got a number of them including I believe nrepl, which is now 0.1.6-preview. Once I did this I was unable to c-x c-e (I got an error about no lisp subprocess). Working with Phil on IRC it was discovered that nrepl-interaction-mode was not enabled for my .clj buffer.
After further fiddling about I found I did not have the line
(add-hook 'nrepl-interaction-mode 'paredit-mode)
in my init so I added it, at which point it all began working again as expected. For testing I commented out that one line and once I do that nrepl-interaction-mode again fails to be enabled for .clj buffers after running nrepl. Is this line required? Perhaps because I have paredit (via starter-kit)? If so, that should be clearer I think.
See http://paste.lisp.org/+2V9O for my init.el, with the line commented out, but most importantly other info which may help diagnose this.