Skip to content

Instantly share code, notes, and snippets.

@remvee
Created June 1, 2010 12:51
Show Gist options
  • Save remvee/420911 to your computer and use it in GitHub Desktop.
Save remvee/420911 to your computer and use it in GitHub Desktop.
launch lein swank and connect with slime
;; easy lein swanking
(defun lein-swank ()
(interactive)
(shell-command "lein swank&" "*lein-swank*")
(with-current-buffer "*lein-swank*"
(let ((timeout 10))
(while (and (> timeout 0)
(not (progn (goto-char (point-min))
(search-forward-regexp "Connection opened on local port +\\([0-9]+\\)" nil t)))
(not (progn (goto-char (point-min))
(search-forward "No project.clj found" nil t))))
(message "Waiting for swank ..%s.." timeout)
(sleep-for 1)
(decf timeout))
(let ((port (match-string 1)))
(if port
(progn
(goto-char (point-min))
(search-forward-regexp "Connection opened on local port +\\([0-9]+\\)")
(slime-connect "localhost" (match-string 1)))
(message "No swank found.."))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment