1

So I start up emacs open foo.lisp then I would start slime and the window splits nicely. Except I don't want to start slime manually.

So is it possible to switch to or startup slime when I open an appropriate file?

Such that my file buffer splits and slime is to the side below whatever.

(defun start-or-switch-to (function buffer-name)
  (if (not (get-buffer buffer-name))
      (progn
        (split-window-sensibly (selected-window))
        (other-window 1)
        (funcall function))
    (switch-to-buffer-other-window buffer-name)))

I have found this snippet of code. And tried to execute it with a

(add-hook.....)

This however shoves the opened file and opens slime on both sides of the split.

1

Using (slime) by itself already splits the buffer, so a separate function to split the buffer is unneeded. By itself it's a one-liner, but to avoid annoying questions and unintended restarts, we need one more statement to check if a slime process is already running:

(add-hook 'lisp-mode-hook '(lambda () 
                              (unless (get-process "SLIME Lisp")
                                (slime))))

Works for me at both start-up and in the middle of a session. If you don't want the cursor to bounce to the REPL, you can use

(add-hook 'lisp-mode-hook '(lambda ()
                                  (unless (get-process "SLIME Lisp")
                                     (let ((oldbuff (current-buffer)))
                                       (slime)
                                       (switch-buffer oldbuff))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.