[ANN] nrepl.el 0.1.4 released

979 views
Skip to first unread message

Tim King

unread,
Sep 18, 2012, 9:54:56 AM9/18/12
to clo...@googlegroups.com, nrep...@googlegroups.com
I am happy to announce the release of nrepl.el v0.1.4, an Emacs client for nREPL.


v0.1.4 is available now on Marmalade, and should also be available on Melpa.
See the github Readme for installation and usage instructions.

Notable additions since our last release:
 - Improvements and simplifications for completion (Tassilo Horn)
 - Fix paredit .. don't make clojure-mode-map parent of nrepl-interaction-mode-map (Tassilo Horn)
 - Documentation additions and fixes (Ryan Fowler, Nikita Beloglazov, Bozhidar Batsov, Juha Syrjälä, Philipp Meier)
 - Make completion back-end and error handler configurable (Hugo Duncan)
 - Accept host as well as port on connect (Ken Restivo)
 - Enable nrepl-interaction-mode in clojurescript-mode (Nelson Morris)
 - Emit stdout from interactive evaluations into the repl buffer
 - Various bug fixes:
   - Fixes for ECB interop (Matthew Willson)
   - Namespace qualify tooling calls (Justin Kramer)
   - Eldoc fixes (Jack Moffitt)
   - Fix path quoting in load file for Windows (Philipp Meier)
   - Fix nREPL / Emacs error "Unable to resolve symbol: if-let"

Many thanks to all the contributors who have reported issues and submitted pull requests.

Cheers,
Tim

Stefan Hübner

unread,
Sep 19, 2012, 1:52:37 AM9/19/12
to clo...@googlegroups.com
I get the the following error when trying to auto-complete e.g. "(pri":

--8<---------------cut here---------------start------------->8---
java.lang.NullPointerException: null
at clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:314)
clojure.stacktrace$print_stack_trace.invoke (stacktrace.clj:51)
clojure.stacktrace$print_stack_trace.invoke (stacktrace.clj:49)
user$eval6701.invoke (nrepl-server.clj:2)
clojure.lang.Compiler.eval (Compiler.java:6465)
clojure.lang.Compiler.eval (Compiler.java:6431)
clojure.core$eval.invoke (core.clj:2795)
clojure.main$repl$read_eval_print__5967.invoke (main.clj:244)
clojure.main$repl$fn__5972.invoke (main.clj:265)
clojure.main$repl.doInvoke (main.clj:265)
clojure.lang.RestFn.invoke (RestFn.java:1096)
clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__768.invoke (interruptible_eval.clj:57)
clojure.lang.AFn.applyToHelper (AFn.java:159)
clojure.lang.AFn.applyTo (AFn.java:151)
clojure.core$apply.invoke (core.clj:600)
clojure.core$with_bindings_STAR_.doInvoke (core.clj:1769)
clojure.lang.RestFn.invoke (RestFn.java:425)
clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke (interruptible_eval.clj:42)
clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__809$fn__811.invoke (interruptible_eval.clj:170)
clojure.core$comp$fn__3758.invoke (core.clj:2276)
clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__802.invoke (interruptible_eval.clj:137)
clojure.lang.AFn.run (AFn.java:24)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask (ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:908)
java.lang.Thread.run (Thread.java:662)
--8<---------------cut here---------------end--------------->8---

I use tools.nrepl 0.2.0-beta9 and clojure-complete 0.2.2

The nREPL server is started with this script (nrepl-server.clj as seen
in stack-trace):

--8<---------------cut here---------------start------------->8---
(use '[clojure.tools.nrepl.server :only [start-server stop-server]])

(defonce server (start-server :port 4005))
(println "nREPL server started at port 4005")
--8<---------------cut here---------------end--------------->8---


-Stefan
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

Timothy Washington

unread,
Sep 19, 2012, 1:40:00 PM9/19/12
to clo...@googlegroups.com
Hey, 

Still a fairly newbie emacs user. But when trying to evaluate a form with C-x C-e ( after M-x nrepl-jack-in ), I still get this error (was happening with nrepl 0.1.3): 

Symbol's function definition is void: lisp-eval-last-sexp


This call looks like it's used in ~/elpa/clojure-mode-1.11.5/clojure-mode.el. I'm using GNU Emacs 24.0.92.1. I also still have these directories lying around. Should something be blown away, or uninstalled? Does clojure-mode need to be updated ( 1.11.5 looks like the latest )? 

~/.emacs.d/swank/
~/.emacs.d/elpa/nrepl-0.1.3/
~/.emacs.d/elpa/nrepl-0.1.4/


Thanks 

Tim Washington 



Tassilo Horn

unread,
Sep 19, 2012, 2:38:26 PM9/19/12
to clo...@googlegroups.com
Timothy Washington <twas...@gmail.com> writes:

Hi Timothy,

> Still a fairly newbie emacs user. But when trying to evaluate a form
> with *C-x C-e ( *after* M-x nrepl-jack-in )*, I still get this error
> (was happening with nrepl 0.1.3):
>
> *Symbol's function definition is void: lisp-eval-last-sexp*
>
> This call looks like it's used in *
> ~/elpa/clojure-mode-1.11.5/clojure-mode.el*.

Hm, I think that's a SLIME function, and clojure-mode currently uses a
bundled SLIME that is compiled when you do clojure-jack-in. With
nrepl.el, you don't do that anymore.

But anyway, once you've nrepl-jack-in'ed all (or the clojure buffers of
that project?) should have nrepl-interaction-mode enabled, and that
binds C-x C-e to nrepl-eval-last-expression.

Does the buffer with the clj file have nrepl-interaction-mode enabled?
You can see that by the nREPL lighter in the mode line or by doing C-h v
nrepl-interaction-mode RET in that buffer. It should say the value is
t.

> I'm using GNU Emacs 24.0.92.1. I also still have these directories
> lying around. Should something be blown away, or uninstalled? Does
> clojure-mode need to be updated ( 1.11.5 looks like the latest )?

No, I use that successfully with nrepl.el, too.

> ~/.emacs.d/swank/
> ~/.emacs.d/elpa/nrepl-0.1.3/

You can probably delete these two.

> ~/.emacs.d/elpa/nrepl-0.1.4/

But not this one.

Bye,
Tassilo

Timothy Washington

unread,
Sep 19, 2012, 2:59:46 PM9/19/12
to clo...@googlegroups.com
Hey Tassilo, thanks for responding. 

Well after M-x nrepl-jack-in, I notice that the "Starting nREPL server..." message never goes away. But I don't think that's the main problem. 

1) That help window looks like the following. So it doesn't look like the nrepl-interaction-mode is enabled on emacs startup. 


-UU-:----F1  neuralnet.clj   Top (16,0)    Git:master  (Clojure Fill) ----...
nrepl-interaction-mode is a variable defined in `nrepl.el'.
Its value is nil

  Automatically becomes buffer-local when set in any fashion.

Documentation:
Non-nil if nREPL-Interaction mode is enabled.
Use the command `nrepl-interaction-mode' to change this variable.


2) After executing the emacs command 'nrepl-interaction-mode', I could then execute C-x C-e, but got the following message 

No buffer named *nrepl-connection*


3) So I went ahead and fired up M-x nrepl, and supplied the host and port. Again, the result message "Connecting to nREPL on localhost:57260..." never goes away (hopefully not the real problem). After this, trying to execute C-x C-e or C-x C-l , gives me the error: 

Wrong type argument: stringp, nil



Tim Washington 



Tassilo Horn

unread,
Sep 19, 2012, 3:31:00 PM9/19/12
to clo...@googlegroups.com
Timothy Washington <twas...@gmail.com> writes:

> Well after *M-x nrepl-jack-in*, I notice that the "*Starting nREPL
> server... *" message never goes away. But I don't *think* that's the
> main problem.

I think, it is. Normally, after that message it takes ~10secs and then
a *nrepl* buffer should pop up. If that doesn't happen for some reason,
then there's something wrong.

> *1)* That help window looks like the following. So it doesn't look
> like the *nrepl-interaction-mode* is enabled on emacs startup.

It's enabled automatically in all clojure buffers as soon as nrepl
successfully started, which doesn't seem to happen for you.

> *2)* After executing the emacs command '*nrepl-interaction-mode*', I could
> then execute *C-x C-e*, but got the following message
>
> No buffer named *nrepl-connection*

Yeah, this buffer is also created once nrepl has successfully started.

> *3)* So I went ahead and fired up *M-x nrepl*, and supplied the host
> and port. Again, the result message "*Connecting to nREPL on
> localhost:57260...*" never goes away (hopefully not the real problem).

Hm, hm, why doesn't it want to connect...

What you could do to debug the issue is open nrepl.el, goto the function
definition of nrepl-jack-in, place point (the emacs cursor) on the
function name, do `M-x edebug-defun RET', and then `M-x nrepl-jack-in
RET'. Now you'll see an arrow in the margin indicating the flow of
control. With `n' you can step one expression further, and the results
are printed in the echo area. What are those values? Especially the
result of `start-process-shell-command' might give a clue.

Bye,
Tassilo

Timothy Washington

unread,
Sep 19, 2012, 4:06:00 PM9/19/12
to clo...@googlegroups.com
Oooh, this is interesting... Well the code block is below, and you can see where the arrow is stopping on execution. 

;;;###autoload                                                                                                                                                                                                                                                                                                                                                                                                                    
(defun nrepl-jack-in (prompt-project)
  (interactive "P")
=>(let* ((cmd (if prompt-project                                                                                                                                                                                                                                                                                                                                                                                                  
                  (format "cd %s && %s" (ido-read-directory-name "Project: ")
                          nrepl-server-command)
                  nrepl-server-command))
         (process (start-process-shell-command
                   "nrepl-server" "*nrepl-server*" cmd)))
    (set-process-filter process 'nrepl-server-filter)
    (set-process-sentinel process 'nrepl-server-sentinel)
    (set-process-coding-system process 'utf-8-unix 'utf-8-unix)
    (message "Starting nREPL server...")))


That form has several calls, the first result is nil. The second result error's out with the message below. And this is where execution just dies and goes away 
  • nil
  • Symbol's value as variable is void: nrepl-server-command

I can see in nrepl.el where nrepl-server-command is defined. But I don't know enough about elisp to say what the problem is. 


Tim Washington 




Bye,
Tassilo

Tassilo Horn

unread,
Sep 20, 2012, 2:40:20 AM9/20/12
to clo...@googlegroups.com
Timothy Washington <twas...@gmail.com> writes:

> (defun nrepl-jack-in (prompt-project)
> (interactive "P")
> *=>*(let* ((cmd (if prompt-project
>
>
>
>
>
> (format "cd %s && %s" (ido-read-directory-name "Project:
> ")
> *nrepl-server-command*)
>
> That form has several calls, the first result is nil. The second
> result error's out with the message below. And this is where execution
> just dies and goes away
>
> - nil
> - *Symbol's value as variable is void: nrepl-server-command*

Uh, now that's really strange... It means that nrepl.el hasn't been
loaded yet. `nrepl-jack-in' is an autoloaded function meaning once you
call it, nrepl will be loaded too. That contradicts each other...

I suspect you have some old version laying around somewhere. Please do
`M-x list-load-path-shadows RET' and check if there's some entry like

/foo/bar/nrepl hides ~/.emacs.d/elpa/nrepl-0.1.4/nrepl

If that's not the case, maybe there's something broken in your configs
or some addon. To rule that out, please start emacs using "emacs -Q".
Then copy this code into the *scratch* buffer and evaluate it.

--8<---------------cut here---------------start------------->8---
(progn
(add-to-list 'load-path "~/.emacs.d/elpa/clojure-mode-1.11.5")
(add-to-list 'load-path "~/.emacs.d/elpa/nrepl-0.1.4")
(require 'nrepl)) ;; <== C-x C-e here!
--8<---------------cut here---------------end--------------->8---

Then open some clojure file in some leiningen project and do `M-x
nrepl-jack-in RET'. Does it work then?

Bye,
Tassilo

Timothy Washington

unread,
Sep 20, 2012, 6:01:35 PM9/20/12
to clo...@googlegroups.com
Heyya, thanks for your help so far on this. See comments inlined... 



On Thu, Sep 20, 2012 at 2:40 AM, Tassilo Horn <ts...@gnu.org> wrote:
Timothy Washington <twas...@gmail.com> writes:

> (defun nrepl-jack-in (prompt-project)
>   (interactive "P")
> *=>*(let* ((cmd (if prompt-project
>
>
>
>
>
>                   (format "cd %s && %s" (ido-read-directory-name "Project:
> ")
>                           *nrepl-server-command*)
>
> That form has several calls, the first result is nil. The second
> result error's out with the message below. And this is where execution
> just dies and goes away
>
>    - nil
>    - *Symbol's value as variable is void: nrepl-server-command*

Uh, now that's really strange...  It means that nrepl.el hasn't been
loaded yet.  `nrepl-jack-in' is an autoloaded function meaning once you
call it, nrepl will be loaded too.  That contradicts each other...

I suspect you have some old version laying around somewhere.
 Please do
`M-x list-load-path-shadows RET' and check if there's some entry like

  /foo/bar/nrepl hides ~/.emacs.d/elpa/nrepl-0.1.4/nrepl

The result of this is: 

No Emacs Lisp load-path shadowings were found

 
If that's not the case, maybe there's something broken in your configs
or some addon.  To rule that out,
please start emacs using "emacs -Q".
Then copy this code into the *scratch* buffer and evaluate it.

--8<---------------cut here---------------start------------->8---
(progn
  (add-to-list 'load-path "~/.emacs.d/elpa/clojure-mode-1.11.5")
  (add-to-list 'load-path "~/.emacs.d/elpa/nrepl-0.1.4")
  (require 'nrepl)) ;; <== C-x C-e here!
--8<---------------cut here---------------end--------------->8---

This bit is copied and evaluated in ok in *scratch*. But I get the same hanging "Starting nRepl server..." message, when executing M-x nrepl-jack-in. 


 
Then open some clojure file in some leiningen project and do `M-x
nrepl-jack-in RET'.  Does it work then?

The "Starting nRepl server..." message is still hanging. But I ran the emacs debugger on nrepl, and this time, it got past the "nrepl-server-command" command. The debugger seems to have completed the entire "nrepl-jack-in" function. I'm genuinely at a loss. 


Bye,
Tassilo


Thanks again, and see you. 

Tim 




Tassilo Horn

unread,
Sep 21, 2012, 2:17:24 AM9/21/12
to clo...@googlegroups.com
Timothy Washington <twas...@gmail.com> writes:

>> I suspect you have some old version laying around somewhere. Please
>> do `M-x list-load-path-shadows RET' and check if there's some entry
>> like
>>
>> /foo/bar/nrepl hides ~/.emacs.d/elpa/nrepl-0.1.4/nrepl
>>
>> *The result of this is: *
>
> *No Emacs Lisp load-path shadowings were found*

Ok, so far so good.

>> If that's not the case, maybe there's something broken in your configs
>> or some addon. To rule that out, please start emacs using "emacs -Q".
>> Then copy this code into the *scratch* buffer and evaluate it.
>>
>> --8<---------------cut here---------------start------------->8---
>> (progn
>> (add-to-list 'load-path "~/.emacs.d/elpa/clojure-mode-1.11.5")
>> (add-to-list 'load-path "~/.emacs.d/elpa/nrepl-0.1.4")
>> (require 'nrepl)) ;; <== C-x C-e here!
>> --8<---------------cut here---------------end--------------->8---
>>
>> *This bit is copied and evaluated in ok in *scratch*. But I get the same
> hanging "Starting nRepl server..." message, when executing M-x
> nrepl-jack-in. *

Ok.

>> Then open some clojure file in some leiningen project and do `M-x
>> nrepl-jack-in RET'. Does it work then?
>
> *The **"Starting nRepl server..." message is still hanging. **But I
> ran the emacs debugger on nrepl, and this time, it got past the "
> nrepl-server-command" command. The debugger seems to have completed
> the entire "nrepl-jack-in" function. I'm genuinely at a loss. *

Hm, if that function is completed, it should eventually call the process
sentinel function `nrepl-server-sentinel'. Try do edebug that one. Is
it ever reached?

If not, what's the contents of the " *nrepl-server*" buffer?

Bye,
Tassilo

Timothy Washington

unread,
Sep 21, 2012, 12:02:16 PM9/21/12
to clo...@googlegroups.com
Ok, I got it. It was very interesting. The debugger never got to "nrepl-server-sentinel". But the *nrepl-server* buffer said: 

REPL started; server listening on localhost port 54922
Exception Unsupported option(s) supplied: :headless  clojure.core/load-libs (core.clj:5266)
clojure.core=>


The nrepl-server-command function in nrepl.el, has that :headless option to a repl option, of what I assumed was a lein command. 

(defcustom nrepl-server-command
  (if (or (locate-file nrepl-lein-command exec-path)
          (locate-file (format "%s.bat" nrepl-lein-command) exec-path))
      (format "%s repl :headless" nrepl-lein-command)                                                                                                                                                                                                                                                                                                                                                                             
    (format "echo \"%s repl :headless\" | $SHELL -l" nrepl-lein-command))
  "The command used to start the nREPL via nrepl-jack-in.                                                                                                                                                                                                                                                                                                                                                                         
For a remote nREPL server lein must be in your PATH.  The remote                                                                                                                                                                                                                                                                                                                                                                  
proc is launched via sh rather than bash, so it might be necessary                                                                                                                                                                                                                                                                                                                                                                
to specific the full path to it. Localhost is assumed."
  :type 'string
  :group 'nrepl-mode)


I dug around a bit and found this issue. That was the clue I needed to solved the problem. I have several lein executables in my path. I made lein.2 the default lein, and now I can "M-x nrepl-jack-in", and execute "C-x C-e". So everything works. Thanks very much for the help. I think this is another step on the road to me being emacs-ified. 


Tim Washington 
Reply all
Reply to author
Forward
0 new messages