-
-
Save michalmarczyk/455153 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 hidden or 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
(defun lein-swank () | |
(interactive) | |
(let ((default-directory (locate-dominating-file default-directory "project.clj"))) | |
(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" (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