Skip to content

Instantly share code, notes, and snippets.

@tobias
Created October 22, 2013 20:59
Show Gist options
  • Save tobias/7108058 to your computer and use it in GitHub Desktop.
Save tobias/7108058 to your computer and use it in GitHub Desktop.
(defun nrepl-port-from-file (file)
"Attempts to read port from a file named by FILE."
(let* ((dir (nrepl-project-directory-for (nrepl-current-dir)))
(f (expand-file-name file dir)))
(when (file-exists-p f)
(with-temp-buffer
(insert-file-contents f)
(buffer-string)))))
(defun nrepl-default-port ()
"Attempt to read port from .nrepl-port or target/repl-port.
Falls back to `nrepl-port' if not found."
(or (nrepl-port-from-file ".nrepl-port")
(nrepl-port-from-file "target/repl-port")
nrepl-port))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment