Skip to content

Commit 13256ec

Browse files
aibabbatsov
authored andcommitted
[#1544] Add defcustom cider-infer-remote-nrepl-ports (#2506)
1 parent 8c00eca commit 13256ec

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* [#2482](https://github.com/clojure-emacs/cider/issues/2482): Don't bind nREPL server started by `cider-jack-in` to `::` (use `localhost` instead).
3030
* [#2484](https://github.com/clojure-emacs/cider/pull/2484): Fix issues where some functionality in REPL buffers (like eldoc) was broken.
3131
* [#2484](https://github.com/clojure-emacs/cider/pull/2484): REPL types are now symbols instead of strings.
32+
* [#1544](https://github.com/clojure-emacs/cider/issues/1544): Add a new defcustom `cider-infer-remote-nrepl-ports` to control whether we use tramp/ssh to infer remote ports. Now defaulting to `nil` (previously it always tried to infer).
3233

3334
## 0.18.0 (2018-09-02)
3435

cider.el

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,12 @@ Tramp version starting 26.1 is using a `cl-defstruct' rather than vanilla VEC."
13271327
(make-tramp-file-name :method (elt vec 0)
13281328
:host (elt vec 2)))))
13291329

1330+
(defcustom cider-infer-remote-nrepl-ports nil
1331+
"When true, cider will use ssh to try to infer nREPL ports on remote hosts."
1332+
:type 'boolean
1333+
:safe #'booleanp
1334+
:package-version '(cider . "0.19.0"))
1335+
13301336
(defun cider--infer-ports (host ssh-hosts)
13311337
"Infer nREPL ports on HOST.
13321338
Return a list of elements of the form (directory port). SSH-HOSTS is a list
@@ -1338,14 +1344,15 @@ of remote SSH hosts."
13381344
(let* ((change-dir-p (file-remote-p default-directory))
13391345
(default-directory (if change-dir-p "~/" default-directory)))
13401346
(cider-locate-running-nrepl-ports (unless change-dir-p default-directory)))
1341-
(let ((vec (vector "sshx" nil host "" nil))
1342-
;; change dir: user might want to connect to a different remote
1343-
(dir (when (file-remote-p default-directory)
1344-
(with-parsed-tramp-file-name default-directory cur
1345-
(when (string= cur-host host) default-directory)))))
1346-
(tramp-maybe-open-connection (cider--tramp-file-name vec))
1347-
(with-current-buffer (tramp-get-connection-buffer (cider--tramp-file-name vec))
1348-
(cider-locate-running-nrepl-ports dir))))))
1347+
(when cider-infer-remote-nrepl-ports
1348+
(let ((vec (vector "sshx" nil host "" nil))
1349+
;; change dir: user might want to connect to a different remote
1350+
(dir (when (file-remote-p default-directory)
1351+
(with-parsed-tramp-file-name default-directory cur
1352+
(when (string= cur-host host) default-directory)))))
1353+
(tramp-maybe-open-connection (cider--tramp-file-name vec))
1354+
(with-current-buffer (tramp-get-connection-buffer (cider--tramp-file-name vec))
1355+
(cider-locate-running-nrepl-ports dir)))))))
13491356

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

doc/up_and_running.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,22 @@ reads for the host and port prompts when you invoke
113113
'(("host-a" "10.10.10.1" "7888")
114114
("host-b" "7888")))
115115
```
116+
117+
## SSH
118+
119+
In some circumstances, cider can try to use SSH to either:
120+
121+
* Tunnel a connection over SSH.
122+
* Infer the remote nREPL port for a direct connection.
123+
124+
This behavior is controlled by two options (both default `nil`):
125+
126+
* `nrepl-use-ssh-fallback-for-remote-hosts`: When true, attempt to connect via ssh
127+
to remote hosts when unable to connect directly.
128+
* `cider-infer-remote-nrepl-ports`: When true, cider will use ssh to try to infer
129+
nREPL ports on remote hosts (for a direct connection).
130+
131+
Note that enabling either of these causes cider to use
132+
[tramp](https://www.gnu.org/software/tramp/) for some SSH operations, which parses
133+
config files such as `~/.ssh/config` and `~/.ssh/known_hosts`. This is known to
134+
cause problems with complex or nonstandard ssh configs.

0 commit comments

Comments
 (0)