   (comint-send-string proc (concat string "\n")))
 
 (defun run-kilns ()
-  "Switch to the kilns window if runing, otherwise Launch the Kilns interpreter in a comint window."
+  "Switch to the kilns window if runing, otherwise Launch the Kilns interpreter
+   in a comint window."
   (interactive)
   (pop-to-buffer (process-buffer (inferior-kilns-process)))
   (goto-char (process-mark (inferior-kilns-process))))


(defvar kilns-minor-mode-map ()
  (let ((map (make-sparse-keymap)))
	(define-key map "\C-c\C-s" 'run-kilns)
	map))

(defvar inferior-kilns-buffer nil
  "Buffer that the kilns process runs in")

(defun inferior-kilns-process ()
  "Returns the current kilns process, or starts up a new one"
  (if (buffer-live-p inferior-kilns-buffer)
      (get-buffer-process inferior-kilns-buffer)
    (progn
      (inferior-kilns-start-process)
      (inferior-kilns-process))))

(defun inferior-kilns-start-process ()
  "Actually start the kilns interpreter.

   This sets the current directory to the path of the kilns binary before
   launching kilns. I am not 100% sure this is the proper way to do it, but it
   does seem the most convenient."
  (let ((old-dir default-directory))
    (cd inferior-kilns-binary-path)
    (setq inferior-kilns-buffer
          (make-comint "Kilns"
                       (concat inferior-kilns-binary-path
                               inferior-kilns-binary)))
    (with-current-buffer inferior-kilns-buffer
      (inferior-kilns-mode)
      (run-hooks 'inferior-kilns-hook))
    (cd old-dir)))

(provide 'kilns-minor-mode)

