Skip to content

Commit

Permalink
add defcustom cider-use-ssh-to-infer-remote-ports, may address clojur…
Browse files Browse the repository at this point in the history
  • Loading branch information
aiba committed Nov 2, 2018
1 parent cb735cc commit 42d4b50
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions cider.el
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,11 @@ Tramp version starting 26.1 is using a `cl-defstruct' rather than vanilla VEC."
(make-tramp-file-name :method (elt vec 0)
:host (elt vec 2)))))

(defcustom cider-use-ssh-to-infer-remote-nrepl-ports t
"When true, cider will use ssh to try to infer nREPL ports on remote hosts."
:type 'boolean
:safe #'booleanp)

(defun cider--infer-ports (host ssh-hosts)
"Infer nREPL ports on HOST.
Return a list of elements of the form (directory port). SSH-HOSTS is a list
Expand All @@ -1338,14 +1343,15 @@ of remote SSH hosts."
(let* ((change-dir-p (file-remote-p default-directory))
(default-directory (if change-dir-p "~/" default-directory)))
(cider-locate-running-nrepl-ports (unless change-dir-p default-directory)))
(let ((vec (vector "sshx" nil host "" nil))
;; change dir: user might want to connect to a different remote
(dir (when (file-remote-p default-directory)
(with-parsed-tramp-file-name default-directory cur
(when (string= cur-host host) default-directory)))))
(tramp-maybe-open-connection (cider--tramp-file-name vec))
(with-current-buffer (tramp-get-connection-buffer (cider--tramp-file-name vec))
(cider-locate-running-nrepl-ports dir))))))
(when cider-use-ssh-to-infer-remote-nrepl-ports
(let ((vec (vector "sshx" nil host "" nil))
;; change dir: user might want to connect to a different remote
(dir (when (file-remote-p default-directory)
(with-parsed-tramp-file-name default-directory cur
(when (string= cur-host host) default-directory)))))
(tramp-maybe-open-connection (cider--tramp-file-name vec))
(with-current-buffer (tramp-get-connection-buffer (cider--tramp-file-name vec))
(cider-locate-running-nrepl-ports dir)))))))

(defun cider--completing-read-port (host ports)
"Interactively select port for HOST from PORTS."
Expand Down

0 comments on commit 42d4b50

Please sign in to comment.