(defun lein-swank ()
  (interactive)
  (let ((root (locate-dominating-file default-directory "project.clj")))
    (or root (error "Not in a Leiningen project."))
    (shell-command (format "cd %s && lein swank %s &" root 4009)
                   "*lein-swank*")
    (set-process-filter (get-buffer-process "*lein-swank*")
                        ;; gAAAAAAAAAAAH! no leixcal scope? what is this, 1970?
                        (lambda (process output)
                          (when (string-match "Connection opened on" output)
                            (slime-connect "localhost" 4009)
                            (set-process-filter process nil))))
    (message "Starting swank server...")))

Generated by Phil Hagelberg using scpaste at Wed Aug 18 12:28:07 2010. PDT. (raw)