@@ -848,19 +848,20 @@ is greater than 10.
848848 (should (string-equal (file-remote-p "/method:[::1]:" 'localname) ""))
849849 (should (string-equal (file-remote-p "/method:[::1]:" 'hop) nil))
850850
851- ;; No expansion.
851+ ;; No expansion. Hop.
852852 (should (string-equal
853- (file-remote-p "/method:user@[::1]:")
854- (format "/%s:%s@%s:" "method" "user" "[::1]")))
853+ (file-remote-p "/method:user@[::1]#1234 :")
854+ (format "/%s:%s@%s#%s :" "method" "user" "[::1]" "1234 ")))
855855 (should (string-equal
856- (file-remote-p "/method:user@[::1]:" 'method) "method"))
857- (should
858- (string-equal (file-remote-p "/method:user@[::1]:" 'user) "user"))
859- (should
860- (string-equal ( file-remote-p "/method:user@[::1]:" 'host) "::1"))
856+ (file-remote-p "/method:user@[::1]#1234 :" 'method) "method"))
857+ (should (string-equal (file-remote-p "/method:user@[::1]#1234:" 'user)
858+ "user"))
859+ (should (string-equal
860+ (file-remote-p "/method:user@[::1]#1234 :" 'host) "::1#1234 "))
861861 (should (string-equal
862- (file-remote-p "/method:user@[::1]:" 'localname) ""))
863- (should (string-equal (file-remote-p "/method:user@[::1]:" 'hop) nil))
862+ (file-remote-p "/method:user@[::1]#1234:" 'localname) ""))
863+ (should (string-equal
864+ (file-remote-p "/method:user@[::1]#1234:" 'hop) nil))
864865
865866 ;; Local file name part.
866867 (should (string-equal (file-remote-p "/-:host:/:" 'localname) "/:"))
@@ -1244,6 +1245,20 @@ is greater than 10.
12441245 (should (string-equal (file-remote-p "/user@[::1]:" 'localname) ""))
12451246 (should (string-equal (file-remote-p "/user@[::1]:" 'hop) nil))
12461247
1248+ ;; No expansion. Hop.
1249+ (should (string-equal
1250+ (file-remote-p "/user@[::1]#1234:")
1251+ (format "/%s@%s#%s:" "user" "[::1]" "1234")))
1252+ (should (string-equal
1253+ (file-remote-p "/user@[::1]#1234:" 'method) "default-method"))
1254+ (should
1255+ (string-equal (file-remote-p "/user@[::1]#1234:" 'user) "user"))
1256+ (should
1257+ (string-equal (file-remote-p "/user@[::1]#1234:" 'host) "::1#1234"))
1258+ (should
1259+ (string-equal (file-remote-p "/user@[::1]#1234:" 'localname) ""))
1260+ (should (string-equal (file-remote-p "/user@[::1]#1234:" 'hop) nil))
1261+
12471262 ;; Local file name part.
12481263 (should (string-equal (file-remote-p "/host:/:" 'localname) "/:"))
12491264 (should (string-equal (file-remote-p "/host::" 'localname) ":"))
@@ -1886,19 +1901,20 @@ is greater than 10.
18861901 (should (string-equal (file-remote-p "/[method/::1]" 'localname) ""))
18871902 (should (string-equal (file-remote-p "/[method/::1]" 'hop) nil))
18881903
1889- ;; No expansion.
1904+ ;; No expansion. Hop.
1905+ (should (string-equal
1906+ (file-remote-p "/[method/user@::1#1234]")
1907+ (format "/[%s/%s@%s#%s]" "method" "user" "::1" "1234")))
18901908 (should (string-equal
1891- (file-remote-p "/[method/user@::1]")
1892- (format "/[%s/%s@%s]" "method" "user" "::1")))
1909+ (file-remote-p "/[method/user@::1#1234]" 'method) "method"))
18931910 (should (string-equal
1894- (file-remote-p "/[method/user@::1]" 'method ) "method "))
1911+ (file-remote-p "/[method/user@::1#1234 ]" 'user ) "user "))
18951912 (should (string-equal
1896- (file-remote-p "/[method/user@::1]" 'user ) "user "))
1913+ (file-remote-p "/[method/user@::1#1234 ]" 'host ) "::1#1234 "))
18971914 (should (string-equal
1898- (file-remote-p "/[method/user@::1]" 'host ) "::1 "))
1915+ (file-remote-p "/[method/user@::1#1234 ]" 'localname ) ""))
18991916 (should (string-equal
1900- (file-remote-p "/[method/user@::1]" 'localname) ""))
1901- (should (string-equal (file-remote-p "/[method/user@::1]" 'hop) nil))
1917+ (file-remote-p "/[method/user@::1#1234]" 'hop) nil))
19021918
19031919 ;; Local file name part.
19041920 (should (string-equal (file-remote-p "/[/host]/:" 'localname) "/:"))
@@ -2425,16 +2441,22 @@ This checks also `file-name-as-directory', `file-name-directory',
24252441 ;; which ruins the tests.
24262442 (let ((tramp-default-method
24272443 (file-remote-p ert-remote-temporary-file-directory 'method))
2428- (host (file-remote-p ert-remote-temporary-file-directory 'host)))
2444+ (host-port
2445+ (file-remote-p ert-remote-temporary-file-directory 'host)))
24292446 (dolist
24302447 (file
24312448 `(,(format "/%s::" tramp-default-method)
24322449 ,(format
24332450 "/-:%s:"
2434- (if (string-match-p tramp-ipv6-regexp host)
2435- (concat
2436- tramp-prefix-ipv6-format host tramp-postfix-ipv6-format)
2437- host))))
2451+ ;; `(file-remote-p ... 'host)' eliminates IPv6
2452+ ;; delimiters. Add them.
2453+ (if (string-match tramp-ipv6-regexp host-port)
2454+ (replace-match
2455+ (format
2456+ "%s\\&%s"
2457+ tramp-prefix-ipv6-format tramp-postfix-ipv6-format)
2458+ nil nil host-port)
2459+ host-port))))
24382460 (should (string-equal (directory-file-name file) file))
24392461 (should
24402462 (string-equal
@@ -4796,8 +4818,11 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
47964818 (host (file-remote-p ert-remote-temporary-file-directory 'host))
47974819 (orig-syntax tramp-syntax)
47984820 (minibuffer-completing-file-name t))
4799- (when (and (stringp host) (string-match tramp-host-with-port-regexp host))
4800- (setq host (match-string 1 host)))
4821+ (when (and (stringp host)
4822+ (string-match
4823+ (rx (regexp tramp-prefix-port-regexp) (regexp tramp-port-regexp))
4824+ host))
4825+ (setq host (replace-match "" nil nil host)))
48014826
48024827 (unwind-protect
48034828 (dolist (syntax (if (tramp--test-expensive-test-p)
@@ -4930,8 +4955,11 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
49304955 (orig-syntax tramp-syntax)
49314956 (non-essential t)
49324957 (inhibit-message t))
4933- (when (and (stringp host) (string-match tramp-host-with-port-regexp host))
4934- (setq host (match-string 1 host)))
4958+ (when (and (stringp host)
4959+ (string-match
4960+ (rx (regexp tramp-prefix-port-regexp) (regexp tramp-port-regexp))
4961+ host))
4962+ (setq host (replace-match "" nil nil host)))
49354963
49364964 ;; (trace-function #'tramp-completion-file-name-handler)
49374965 ;; (trace-function #'completion-file-name-table)
0 commit comments