summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Iba <ai@aaroniba.net>2018-12-21 15:59:28 -0500
committerBozhidar Batsov <bozhidar.batsov@gmail.com>2018-12-21 22:59:28 +0200
commit13256ec0c8d74ed235c8368551e0c0cdc981b5e5 (patch)
tree9cadcfb48fed171868a5c74d4b03a7a6f0dd8845
parent8c00ecaf6a5eba9867f7b30a8c2c8f2eff3e059a (diff)
[#1544] Add defcustom cider-infer-remote-nrepl-ports (#2506)
-rw-r--r--CHANGELOG.md1
-rw-r--r--cider.el23
-rw-r--r--doc/up_and_running.md19
3 files changed, 35 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6896139c..b0b706a5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -29,6 +29,7 @@
* [#2482](https://github.com/clojure-emacs/cider/issues/2482): Don't bind nREPL server started by `cider-jack-in` to `::` (use `localhost` instead).
* [#2484](https://github.com/clojure-emacs/cider/pull/2484): Fix issues where some functionality in REPL buffers (like eldoc) was broken.
* [#2484](https://github.com/clojure-emacs/cider/pull/2484): REPL types are now symbols instead of strings.
+* [#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).
## 0.18.0 (2018-09-02)
diff --git a/cider.el b/cider.el
index f593d802..e82411fc 100644
--- a/cider.el
+++ b/cider.el
@@ -1327,6 +1327,12 @@ 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-infer-remote-nrepl-ports nil
+ "When true, cider will use ssh to try to infer nREPL ports on remote hosts."
+ :type 'boolean
+ :safe #'booleanp
+ :package-version '(cider . "0.19.0"))
+
(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
@@ -1338,14 +1344,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-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."
diff --git a/doc/up_and_running.md b/doc/up_and_running.md
index a1eb503a..00123c30 100644
--- a/doc/up_and_running.md
+++ b/doc/up_and_running.md
@@ -113,3 +113,22 @@ reads for the host and port prompts when you invoke
'(("host-a" "10.10.10.1" "7888")
("host-b" "7888")))
```
+
+## SSH
+
+In some circumstances, cider can try to use SSH to either:
+
+* Tunnel a connection over SSH.
+* Infer the remote nREPL port for a direct connection.
+
+This behavior is controlled by two options (both default `nil`):
+
+* `nrepl-use-ssh-fallback-for-remote-hosts`: When true, attempt to connect via ssh
+ to remote hosts when unable to connect directly.
+* `cider-infer-remote-nrepl-ports`: When true, cider will use ssh to try to infer
+ nREPL ports on remote hosts (for a direct connection).
+
+Note that enabling either of these causes cider to use
+[tramp](https://www.gnu.org/software/tramp/) for some SSH operations, which parses
+config files such as `~/.ssh/config` and `~/.ssh/known_hosts`. This is known to
+cause problems with complex or nonstandard ssh configs.