technomancy / swank-clojure

Swank/slime support for clojure
Eclipse Public License 1.0
412 stars 83 forks source link

In Windows a java process remains in memory after the Emacs shutdown #77

Closed GChristensen closed 12 years ago

GChristensen commented 13 years ago

I suspect, this happens because there are two processes have been created during the jack-in procedure - one belongs to leiningen and another to swank-clojure, but only one of them (leiningen) is associated with an Emacs buffer. As I understand, currently the only graceful solution for this problem is to use (System/exit 0) from the REPL, but is it possible to assotiate the swank-clojure process with another buffer, for example, or is it should a swank-clojure process be associated with a Emacs buffer?

GChristensen commented 13 years ago

Currently I use the following clumsy workaround, but it works for me (may be it's worth to store a reference to the swank-clojure process in a swank buffer local variable instead of global one):

; clojure-mode.el.patch

--- /site/.emacs.d/clojure-mode.el  Sun Nov 06 01:01:44 2011
+++ /clojure-mode.el    Tue Nov 08 14:18:09 2011
@@ -885,7 +885,7 @@
                               (insert output))
                             (when (string-match "proceed to jack in" output)
                               (eval-buffer (process-buffer process))
-                              (slime-connect "localhost" port)
+                              (setq *swank-clojure-connection* (slime-connect "localhost" port))
                               (with-current-buffer (slime-output-buffer t)
                                 (setq default-directory dir))
                               (set-process-sentinel process nil)
;.emacs

(add-hook 'kill-emacs-hook
          (lambda ()
            (when (get-process "swank")
              (let ((slime-dispatching-connection *swank-clojure-connection*))
                (slime-eval-async '(swank:quit-lisp))))))
technomancy commented 12 years ago

This is actually a Leiningen bug: https://github.com/technomancy/leiningen/issues/322