Skip to content

Commit 4eb5ad0

Browse files
valignatevproofit404
authored andcommitted
Fix getting remote port (#8)
* Fix getting remote port tramp-file-name-host returns hostname without the hash-port part * get remote port, compatible with emacs 25 and 26 * Clarify on port type check in pythonic-remote-port
1 parent 6e4824d commit 4eb5ad0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pythonic.el

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,12 @@
7777

7878
(defun pythonic-remote-port ()
7979
"Get port of the connection to the remote python interpreter."
80-
(let ((hostname (tramp-file-name-host (tramp-dissect-file-name (pythonic-aliased-path default-directory)))))
81-
(when (s-contains-p "#" hostname)
82-
(string-to-number (replace-regexp-in-string "\\`.*#" "" hostname)))))
80+
(let ((port (tramp-file-name-port (tramp-dissect-file-name (pythonic-aliased-path default-directory)))))
81+
;; In Emacs 25, `tramp-file-name-port' returns number,
82+
;; in Emacs 26, it returns string. This condition makes them compatible.
83+
(if (stringp port)
84+
(string-to-number port)
85+
port)))
8386

8487

8588
;;; File names.

0 commit comments

Comments
 (0)