tags:

views:

100

answers:

4

I set up my Emacs for Clojure using the instructions at Clojure's web site. I used the first option in setting up the inferior-lisp-program variable, basically "java clojure.main".

With this setup, C-c C-z works in getting me to the Clojure REPL. However, when I'm editing a file and I type C-c C-l to load the file into the REPL, Emacs always switches buffer from the code window to the REPL window. This is very irritating. This happens even when I have two windows veritically split, with code on the left and the REPL on the right. I end up with two mirrored REPL windows.

I remember Clojure Box, which is Emacs + Clojure on Windows, does this right, so I know it's a setup issue.

How do I get Emacs to just switch to the window on the right?

+1  A: 

I use C-c C-k to compile the current buffer. Then the result of that compilation will be available to you in whatever buffer the REPL is running in. Emacs will not switch any buffers around: you're simply compiling the buffer.

Isaac Hodes
A: 

I'm using SLIME with version 20100404, and this doesn't happen to me, not with C-c C-l nor with C-c C-k. Maybe you're using a different slime.el version? Use M-x find-library <RET> slime <RET> and look for its version in the top comments, to check this out.

Edgar
+1  A: 

In clojure-mode v 1.7.1, which I think is the most recent, C-c C-l is bound to clojure-load-file', which has a hard-coded (switch-to-lisp t) at the end of it. In other words, there is no way to prevent it from switching to lisp without redefining switch-to-lisp to check a variable to see whether it should actually invoke.

That said, clojure-load-file seems a bit heavy-handed in most cases. My usual workflow involves setting the region to the whole buffer and invoking lisp-eval-region with C-c C-r. This function accepts an option and-go parameter that indicates whether or not it should switch to the inferior-lisp process buffer or not after invocation.

As I continue working, I usually redefine a functions and evaluate them as I go with lisp-eval-last-sexp which I invoke with C-c C-e, which also accepts the optional and-go flag.

R. P. Dillon
Sounds like this needs to be fixed in clojure-mode.el; that's a terrible default behaviour. (I have never used clojure-load-file.)
technomancy
A: 

In inf-lisp.el you can see that it adds "* inferior-lisp *" to the list of same-buffer windows:

(add-hook 'same-window-buffer-names "*inferior-lisp*")

To remove it from this list, you can put in your .emacs:

(setq same-window-buffer-names (delete "*inferior-lisp*" same-window-buffer-names))
link0ff