Error remains once I got it while using swank-clojure - emacs

I use Emacs for clojure development, because Swank-clojure is a great tool.
But once I get an error on slime-repl buffer, the error remains, though I fixed it or it's no more.
Reproducing way:
Create a clojure project with a leiningen. $lein new myproject.
At core.clj, define a function that (defn f [] (+ 1 1))
Start a swank-clojure. M-x clojure-jack-in.
On a slime-repl buffer, evaluate (f). Of course it returns 2.
On a slime-repl buffer, evaluate (g). Of course it gets error Unable to resolve symbol: g in this context
After that, this error always appears when I try to evaluate anything in the slime-repl buffer.
C-c C-k doesn't help. So I always restart Emacs.app when I got an error on slime-repl buffer.
My Environment:
Mac OS 10.7.3, Cocoa Emacs 23.4.1, clojure-mode 1.11.5(from a Marmalade), leiningen 1.7.0.

In order to confirm an error and close the debugger, hit Q in the debugger window. (There may be restarts other than the QUIT restart available, but this, at least, should always work.)

Related

Emacs, Clojure, lein and nrepl: *nrepl* buffer shows up blank

I created a new project with lein. I open core.clj in emacs. I make sure to run M-x clojure-mode, and M-x nrepl-enable-on-existing-clojure-buffers.
Then I run M-x nrepl-jack-in and in the mini-buffer I get
Starting nREPL server...
followed by a message such as:
Connected. You're bound to be unhappy if you optimize everything.
-Donald Knuth
I see that the buffer name is *nrepl*, but the buffer does not contain a Clojure Repl and instead is completely blank.
If I type anything (meaning anything at all,) I get:
Wrong type argument: integer-or-marker-p, nil
If I switch back to my core.clj buffer, and hit C-c C-l,I get the namespaced name of the last function in my buffer in the minibuffer as a result. And if I put my cursor at the end of a function definition and hit C-x C-e, I get:
CompilerException java.lang.RuntimeException: Unable to resolve
symbol: x in this context, compiling:(NO_SOURCE_PATH:1:1)
I tried making a new lein directory with no dependencies using lein new project-name and tried the same steps as above and got the same results.
What else can I check and/or what am I doing wrong?
EDIT: Additional Information
When I type something into the empty *nrepl* buffer and try to press C-x C-e on what I typed, in the mini buffer I get the message:
No Lisp subprocess; see variable `inferior-lisp-buffer'
Also, I am running:
GNU Emacs 24.3.1
Leiningen 2.1.2 on Java 1.6.0_27 OpenJDK 64-Bit Server VM
I just fixed this exact issue on my own setup. Move your .emacs.d to a backup location, and make a backup copy of your .emacs. Make a new .emacs with only the following lines:
(require 'package)
(add-to-list 'package-archives
'("marmalade" .
"http://marmalade-repo.org/packages/"))
(package-initialize)
(require 'clojure-mode)
(require 'nrepl)
Once you install nrepl and clojure-mode via running M-x package-list-packages and installing their respective entries, you will be able to use nrepl.
Add your custom .emacs back in one logical unit at a time, and you should be able to figure out where the conflict was and eliminate it. Be suspicious of anything related to slime / swank.

How can I clear and reload my nrepl session in emacs?

I am working with emacs and nrepl. How can I do the following:
Exit nrepl (currently I just kill the buffer)
Reload everything I was working with in nrepl.
The problem I'm trying to solve by doing this is that when I have loaded an ns form and it has an error, I am unable to load the correct code because it keeps giving me the previous error.
1) Exit the nrepl (currently I just kill the buffer)
M-x nrepl-quit
2) Reload everything in the nrepl. (I have this problem when I haave
loaded the ns, and it has an error. Then I am unable to load the
correct code, it still keeps giving me the previous error)
You can switch to the buffer and use C-c C-k to load the buffer, or just use C-c C-c to eval an expression. Another option would be:
(use :reload 'my.namespace)
in the REPL.
Check out Stuart Sierra's tools for namespace management at the repl, and read the blog post where he explains how to use it effectively. With a little bit of coding discipline, you won't have to exit your nrepl anymore (or less, in any case).
Good luck.

Unable to evaluate form in nrepl + emacs

I have installed the nrepl, clojure-mode and starter-kit-lisp packages. I am able to start the nrepl by opening my .clj file and then M-x nrepl-jack-in.
However when I evaluate any form in my .clj file by C-x C-e, I get the following message:
inferior-lisp-proc: No Lisp subprocess; see variable `inferior-lisp-buffer'
How do I get it right?
I have had this problem a number of times. In all cases, it has been because while nrepl has started, the nrepl minor mode has not been enabled in the clj buffer. As a result, any evaluation attempts fail with this error.
There should be a "nrepl" menu item. If there isn't, this may be your problem. M-x nrepl-enable-on-existing-buffers should fix it.
I had this problem for a while, and now it appears to have gone away; you might want to try installing clojure-mode and nrepl afresh.
Are you sure M-x nrepl-jack-in worked? If it did, you should be prompted with a repl in emacs, like so:
nrepl requires leiningen 2, so make sure that you use the right version in your project and that the nrepl plugin is properly installed.
Also make sure that the major mode when editing your .clj file is clojure-mode.
You might want to post a screenshot to make it easier to spot the problem.

nXhtml is not highlighting PHP code, gives errors on loading

I'm using the latest nXhtml checked out from the repo, and using GNU Emacs version 24.0.91.1. When I open a PHP file it shows as un-syntax-highlighted text, and I get a compile error:
Error: Wrong type argument: number-or-marker-p, nil
and a message in the log:
File mode specification error: (cl-assertion-failed (functionp byte-compiled-fun))
I'm avoiding my .emacs and .emacs.d by running emacs with this command:
emacs -Q --eval '(load "/path/to/nxhtml/autostart")' /path/to/nxhtml/tests/in/heredoc.php
Even if you don't have a fix, how can I go about debugging this issue?
There seem to be a fair amount of such wrong-type-argument errors lately with the development version of Emacs (24). This might represent an Emacs bug. Or it might represent an nXhtml bug.
I suggest starting by notifying Lennart, the nXhtml author, trying to give him a clear recipe, starting from emacs -Q.
If that doesn't help, consider filing an Emacs bug: M-x report-emacs-bug.
To try to debug it a bit yourself, be sure to load only source files (e.g. for nXhtml), i.e., *.el, not *.elc, starting preferably with emacs -Q (no init file). Do M-x set-variable debug-on-error t to see where the error is raised. Then perhaps use M-x debug-on-entry FUNCTION, where FUNCTION is the function where the error seems to have been raised. Then step through the Emacs debugger, hitting d to step and c to skip through a step.
But again, I suggest starting with Lennart.
Try the newest version of Emacs.
I had the same problem (on Windows 7):
Error: Wrong type argument: number-or-marker-p, nil
at line 1471 of nxhtml-loaddefs.el.
Nxhtml seems fine on Emacs 24.1.50.1 (23 April 2012).
http://alpha.gnu.org/gnu/emacs/windows/?C=M;O=D

How can I abort an evaluation in Clojure Box (Emacs)?

I've been caught up in long running computations lately thanks to Project Euler and I'd like to know how to abort an evaluation and return to the REPL prompt. I'm running the standard Clojure Box version of Emacs. I tried the obvious REPL > Interrupt Lisp Process and Slime > Interrupt Command but neither kill the execution and return my REPL prompt.
Hit control c twice. If you're in *slime-repl clojure* then C-c C-c will kill the process and return you to the repl prompt. If you're in the *inferior-lisp* buffer, then you'll probably kill the clojure process, meaning that you'll have to restart slime (with M-x slime). If you don't have a slime repl buffer then, M-x slime-repl should give you one. You can use this as a repl to get a few extra features (try pressing the comma and tab, and see what's available ;)
When things get really fowled you can kill your lisp instance with M-x slime-quit-lisp and then restart it with M-x slime