Skip to content

Commit

Permalink
Make TRAMP functionality work when using non-standard ports
Browse files Browse the repository at this point in the history
  • Loading branch information
vemv committed Aug 18, 2023
1 parent 0348da5 commit 9d2aa2c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 5 additions & 3 deletions cider-common.el
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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)
Expand All @@ -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.
Expand Down
8 changes: 7 additions & 1 deletion test/cider-common-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected]#22:")
(expect (cider-make-tramp-prefix "ssh" "cider-devs" "192.168.50.9")
:to-equal "/ssh:[email protected]#22:")
(expect (cider-make-tramp-prefix "ssh" "cider-devs" "192.168.50.9" "12345")
:to-equal "/ssh:[email protected]#12345:")
(expect (cider-make-tramp-prefix "ssh" "cider-devs" "192.168.50.9#12345")
:to-equal "/ssh:[email protected]#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:")
Expand Down

0 comments on commit 9d2aa2c

Please sign in to comment.