Created
May 30, 2010 22:20
-
-
Save juergenhoetzel/419364 to your computer and use it in GitHub Desktop.
Launch a Leiningen Swank Process and connect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defcustom lein-swank-command "lein" | |
"lein program file name. It is searched for in PATH. You can also | |
set an absolute path, if the Leiningen bin directory is not in your PATH | |
environment." | |
:type 'file | |
:group 'lein-swank) | |
(defun lein-swank (directory) | |
"Start a lein swank process in directory (default `default-directory')" | |
(interactive (list (or | |
(locate-dominating-file default-directory "project.clj") | |
(read-directory-name "Leiningen Project directory: ")))) | |
(let ((default-directory directory)) | |
(when (not default-directory) | |
(error "Not in a Leiningen project.")) | |
;; you can customize slime-port using .dir-locals.el | |
(let ((proc (start-process "lein-swank" nil lein-swank-command "swank" (number-to-string slime-port)))) | |
(when proc | |
(process-put proc :output nil) | |
(set-process-sentinel proc (lambda (proc event) | |
(message "%s%s: `%S'" | |
(process-get proc :output) | |
proc (replace-regexp-in-string "\n" "" event)))) | |
(set-process-filter proc | |
(lambda (proc output) | |
;; record last line of output until connected (possible error message) | |
(process-put proc :output (concat (process-get proc :output) output)) | |
(when (string-match "Connection opened on" output) | |
(slime-connect "localhost" slime-port) | |
;; no need to further process output | |
(set-process-filter proc nil)))) | |
(message "Starting swank server..."))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Moved to http://github.com/vu3rdd/swank-clojure-extra