views:

350

answers:

2

Hi All,

I have a question regarding how to "gracefully exit SLIME", when I quit Emacs. Here is the relevant portion of my config file:

;; SLIME configuration

(setq inferior-lisp-program "/usr/local/bin/sbcl")
(add-to-list 'load-path "~/Scripts/slime/")
(require 'slime)
(slime-setup)

;; configure SLIME to gracefully quit when emacs
;; terminates

(defun slime-smart-quit ()
  (interactive)
  (when (slime-connected-p)
    (if (equal (slime-machine-instance) "Gregory-Gelfonds-MacBook-Pro.local")
 (slime-quit-lisp)
      (slime-disconnect)))
  (slime-kill-all-buffers))

(add-hook 'kill-emacs-hook 'slime-smart-quit)

To my knowledge this should automatically kill SLIME and it's associated processes whenever I exit Emacs. However, every time I exit, I still get the prompt:

Proc       Status   Buffer  Command
----       ------   ------  -------
SLIME Lisp    open      *cl-connection* (network stream connection to 127.0.0.1)
inferior-lisp run      *inferior-lisp* /usr/local/bin/sbcl


Active processes exist; kill them and exit anyway? (yes or no) 

Can someone shed some insight as to what I'm missing from my config?

Thanks in advance.

+1  A: 

One way to debug the problem is to debug the function.

Place your cursor inside the 'slime-smart-quit routine and type M-x edebug-defun. Then exit Emacs as you normally would. You should then be prompted by the Emacs lisp debugger edebug. It's a pretty easy debugger to use (type ? for help).

Step through the code and see where it doesn't do what you expect it to do.

Use q to quit out of the debugger, then make changes, and M-x edebug-defun again to debug the new version.

Repeat until you find success, or have a little more information for the question.

Trey Jackson
+2  A: 

I know it's not exactly what you asked for, but maybe this will be helpful to other noobs like me.

You can execute a SLIME command to exit, so you'll have a nice, clean emacs left over.

In a SLIME buffer, type in , (comma). You're placed in the minibuffer and SLIME asks which command to execute. Type in sayoonara and hit Enter. You should see SLIME exiting, the minibuffer mentions that "Connection closed." and you're placed in the *scratch* buffer.

I wonder if there's some way to simply invoke this "sayoonara" command from your .emacs, as opposed to manually unwiring everything.

Alex Beynenson