branch: elpa/cider commit 012e3fe71fef324856db74d26a29b239c3eceb88 Author: vemv <v...@users.noreply.github.com> Commit: vemv <v...@users.noreply.github.com>
Make TRAMP functionality work when using non-standard ports --- CHANGELOG.md | 1 + cider-common.el | 8 +++++--- test/cider-common-tests.el | 8 +++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 530f7ca036..efd32c4c1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - Recompute namespace info on each fighweel-main recompilation. - Fix the `xref-find-definitions` CIDER backend to return correct filenames. - Fix the `cider-xref-fn-deps` buttons to direct to the right file. +- Make TRAMP functionality work when using non-standard ports. ### Changes diff --git a/cider-common.el b/cider-common.el index 90a7382a5d..4225a5434b 100644 --- a/cider-common.el +++ b/cider-common.el @@ -226,8 +226,8 @@ create a valid path." (match-string 1 filename) filename))) -(defun cider-make-tramp-prefix (method user host) - "Constructs a Tramp file prefix from METHOD, USER, HOST. +(defun cider-make-tramp-prefix (method user host &optional port) + "Constructs a Tramp file prefix from METHOD, USER, HOST, PORT. It originated from Tramp's `tramp-make-tramp-file-name'. The original be forced to make full file name with `with-parsed-tramp-file-name', not providing prefix only option." @@ -240,6 +240,8 @@ prefix only option." (if (string-match tramp-ipv6-regexp host) (concat tramp-prefix-ipv6-format host tramp-postfix-ipv6-format) host)) + (when port + (concat "#" port)) tramp-postfix-host-format)) (defun cider-tramp-prefix (&optional buffer) @@ -253,7 +255,7 @@ if BUFFER is local." (when (tramp-tramp-file-p name) (with-parsed-tramp-file-name name v (with-no-warnings - (cider-make-tramp-prefix v-method v-user v-host)))))) + (cider-make-tramp-prefix v-method v-user v-host v-port)))))) (defun cider--client-tramp-filename (name &optional buffer) "Return the tramp filename for path NAME relative to BUFFER. diff --git a/test/cider-common-tests.el b/test/cider-common-tests.el index b918811b72..92df2bbe71 100644 --- a/test/cider-common-tests.el +++ b/test/cider-common-tests.el @@ -68,9 +68,15 @@ (describe "cider-make-tramp-prefix" (it "returns tramp-prefix only" - ;;; The third parameter is a host. It must contains a port number. + ;;; The third parameter is a host. (expect (cider-make-tramp-prefix "ssh" "cider-devs" "192.168.50.9#22") :to-equal "/ssh:cider-devs@192.168.50.9#22:") + (expect (cider-make-tramp-prefix "ssh" "cider-devs" "192.168.50.9") + :to-equal "/ssh:cider-devs@192.168.50.9#22:") + (expect (cider-make-tramp-prefix "ssh" "cider-devs" "192.168.50.9" "12345") + :to-equal "/ssh:cider-devs@192.168.50.9#12345:") + (expect (cider-make-tramp-prefix "ssh" "cider-devs" "192.168.50.9#12345") + :to-equal "/ssh:cider-devs@192.168.50.9#12345:") ;;; These two cases are for using ssh config alias. (expect (cider-make-tramp-prefix "ssh" nil "test.cider.com") :to-equal "/ssh:test.cider.com:")