(unless (tramp-gvfs-connection-mounted-p vec)
(let ((method (tramp-file-name-method vec))
- (user (tramp-file-name-user vec))
- (host (tramp-file-name-host vec))
+ (user-domain (tramp-file-name-user-domain vec))
+ (host-port (tramp-file-name-host-port vec))
(localname (tramp-file-name-unquote-localname vec))
(object-path
(tramp-gvfs-object-path (tramp-make-tramp-file-name vec 'noloc))))
(with-tramp-progress-reporter
vec 3 (format "Opening connection for %s%s using %s"
- (if (tramp-string-empty-or-nil-p user)
- "" (concat user "@"))
- host method)
+ (if (tramp-string-empty-or-nil-p user-domain)
+ "" (concat user-domain "@"))
+ host-port method)
;; Enable `auth-source'.
(tramp-set-connection-property
(with-timeout
((tramp-get-method-parameter
vec 'tramp-connection-timeout tramp-connection-timeout)
- (if (tramp-string-empty-or-nil-p (tramp-file-name-user vec))
+ (if (tramp-string-empty-or-nil-p user-domain)
(tramp-error
vec 'file-error
- "Timeout reached mounting %s using %s" host method)
+ "Timeout reached mounting %s using %s" host-port method)
(tramp-error
vec 'file-error
- "Timeout reached mounting %s@%s using %s" user host method)))
+ "Timeout reached mounting %s@%s using %s"
+ user-domain host-port method)))
(while (not (tramp-get-file-property vec "/" "fuse-mountpoint"))
(read-event nil nil 0.1)))
;;; Integration of shortdoc.el:
(with-eval-after-load 'shortdoc
- (dolist (elem '((file-remote-p
+ (dolist (elem `((file-remote-p
:eval (file-remote-p "/ssh:user@host:/tmp/foo")
- :eval (file-remote-p "/ssh:user@host:/tmp/foo" 'method))
+ :eval (file-remote-p "/ssh:user@host:/tmp/foo" 'method)
+ :eval (file-remote-p "/ssh:user@[::1]#1234:/tmp/foo" 'host)
+ ;; We don't want to see the text properties.
+ :no-eval (file-remote-p "/sudo::/tmp/foo" 'user)
+ :result ,(substring-no-properties
+ (file-remote-p "/sudo::/tmp/foo" 'user)))
(file-local-name
:eval (file-local-name "/ssh:user@host:/tmp/foo"))
(file-local-copy
"" (concat " " process-name))
(if (tramp-string-empty-or-nil-p l-user)
"" (concat l-user "@"))
- l-host l-method)
+ (tramp-file-name-host-port hop) l-method)
(tramp-send-command vec command t t)
(tramp-process-actions
p vec
(if (tramp-string-empty-or-nil-p
(tramp-file-name-user vec))
"" (concat (tramp-file-name-user vec) "@"))
- (tramp-file-name-host vec)
+ (tramp-file-name-host-port vec)
(tramp-file-name-method vec))
(tramp-open-connection-setup-interactive-shell p vec))
(file-regular-p (file-truename filename))))))))
(defun tramp-handle-file-remote-p (filename &optional identification connected)
- "Like `file-remote-p' for Tramp files."
+ "Like `file-remote-p' for Tramp files.
+It supports the additional IDENTIFICATION `hop'.
+For the `host' IDENTIFICATION, both host name and port number (if
+existing) are returned."
;; We do not want traces in the debug buffer.
(let ((tramp-verbose (min tramp-verbose 3)))
(when (tramp-tramp-file-p filename)
proc "password-vector" (process-get proc 'tramp-vector)))
(key (tramp-make-tramp-file-name vec 'noloc))
(method (tramp-file-name-method vec))
- (user (or (tramp-file-name-user-domain vec)
- (tramp-get-connection-property key "login-as")))
- (host (tramp-file-name-host-port vec))
+ (user-domain (or (tramp-file-name-user-domain vec)
+ (tramp-get-connection-property key "login-as")))
+ (host-port (tramp-file-name-host-port vec))
(pw-prompt
(string-trim-left
(or prompt
(setq auth-info
(car
(auth-source-search
- :max 1 :user user :host host :port method
- :require (cons :secret (and user '(:user)))
- :create (and user t)))
+ :max 1 :user user-domain :host host-port :port method
+ :require (cons :secret (and user-domain '(:user)))
+ :create (and user-domain t)))
tramp-password-save-function
(plist-get auth-info :save-function)
auth-passwd
(should (string-equal (file-remote-p "/method:[::1]:" 'localname) ""))
(should (string-equal (file-remote-p "/method:[::1]:" 'hop) nil))
- ;; No expansion.
+ ;; No expansion. Hop.
(should (string-equal
- (file-remote-p "/method:user@[::1]:")
- (format "/%s:%s@%s:" "method" "user" "[::1]")))
+ (file-remote-p "/method:user@[::1]#1234:")
+ (format "/%s:%s@%s#%s:" "method" "user" "[::1]" "1234")))
(should (string-equal
- (file-remote-p "/method:user@[::1]:" 'method) "method"))
- (should
- (string-equal (file-remote-p "/method:user@[::1]:" 'user) "user"))
- (should
- (string-equal (file-remote-p "/method:user@[::1]:" 'host) "::1"))
+ (file-remote-p "/method:user@[::1]#1234:" 'method) "method"))
+ (should (string-equal (file-remote-p "/method:user@[::1]#1234:" 'user)
+ "user"))
+ (should (string-equal
+ (file-remote-p "/method:user@[::1]#1234:" 'host) "::1#1234"))
(should (string-equal
- (file-remote-p "/method:user@[::1]:" 'localname) ""))
- (should (string-equal (file-remote-p "/method:user@[::1]:" 'hop) nil))
+ (file-remote-p "/method:user@[::1]#1234:" 'localname) ""))
+ (should (string-equal
+ (file-remote-p "/method:user@[::1]#1234:" 'hop) nil))
;; Local file name part.
(should (string-equal (file-remote-p "/-:host:/:" 'localname) "/:"))
(should (string-equal (file-remote-p "/user@[::1]:" 'localname) ""))
(should (string-equal (file-remote-p "/user@[::1]:" 'hop) nil))
+ ;; No expansion. Hop.
+ (should (string-equal
+ (file-remote-p "/user@[::1]#1234:")
+ (format "/%s@%s#%s:" "user" "[::1]" "1234")))
+ (should (string-equal
+ (file-remote-p "/user@[::1]#1234:" 'method) "default-method"))
+ (should
+ (string-equal (file-remote-p "/user@[::1]#1234:" 'user) "user"))
+ (should
+ (string-equal (file-remote-p "/user@[::1]#1234:" 'host) "::1#1234"))
+ (should
+ (string-equal (file-remote-p "/user@[::1]#1234:" 'localname) ""))
+ (should (string-equal (file-remote-p "/user@[::1]#1234:" 'hop) nil))
+
;; Local file name part.
(should (string-equal (file-remote-p "/host:/:" 'localname) "/:"))
(should (string-equal (file-remote-p "/host::" 'localname) ":"))
(should (string-equal (file-remote-p "/[method/::1]" 'localname) ""))
(should (string-equal (file-remote-p "/[method/::1]" 'hop) nil))
- ;; No expansion.
+ ;; No expansion. Hop.
+ (should (string-equal
+ (file-remote-p "/[method/user@::1#1234]")
+ (format "/[%s/%s@%s#%s]" "method" "user" "::1" "1234")))
(should (string-equal
- (file-remote-p "/[method/user@::1]")
- (format "/[%s/%s@%s]" "method" "user" "::1")))
+ (file-remote-p "/[method/user@::1#1234]" 'method) "method"))
(should (string-equal
- (file-remote-p "/[method/user@::1]" 'method) "method"))
+ (file-remote-p "/[method/user@::1#1234]" 'user) "user"))
(should (string-equal
- (file-remote-p "/[method/user@::1]" 'user) "user"))
+ (file-remote-p "/[method/user@::1#1234]" 'host) "::1#1234"))
(should (string-equal
- (file-remote-p "/[method/user@::1]" 'host) "::1"))
+ (file-remote-p "/[method/user@::1#1234]" 'localname) ""))
(should (string-equal
- (file-remote-p "/[method/user@::1]" 'localname) ""))
- (should (string-equal (file-remote-p "/[method/user@::1]" 'hop) nil))
+ (file-remote-p "/[method/user@::1#1234]" 'hop) nil))
;; Local file name part.
(should (string-equal (file-remote-p "/[/host]/:" 'localname) "/:"))
;; which ruins the tests.
(let ((tramp-default-method
(file-remote-p ert-remote-temporary-file-directory 'method))
- (host (file-remote-p ert-remote-temporary-file-directory 'host)))
+ (host-port
+ (file-remote-p ert-remote-temporary-file-directory 'host)))
(dolist
(file
`(,(format "/%s::" tramp-default-method)
,(format
"/-:%s:"
- (if (string-match-p tramp-ipv6-regexp host)
- (concat
- tramp-prefix-ipv6-format host tramp-postfix-ipv6-format)
- host))))
+ ;; `(file-remote-p ... 'host)' eliminates IPv6
+ ;; delimiters. Add them.
+ (if (string-match tramp-ipv6-regexp host-port)
+ (replace-match
+ (format
+ "%s\\&%s"
+ tramp-prefix-ipv6-format tramp-postfix-ipv6-format)
+ nil nil host-port)
+ host-port))))
(should (string-equal (directory-file-name file) file))
(should
(string-equal