(defun tramp-method-regexp ()
"Regexp matching methods identifiers.
The `ftp' syntax does not support methods."
- (if (eq (tramp-compat-tramp-syntax) 'simplified) "" "[a-zA-Z0-9-]+"))
+ (cond ((eq (tramp-compat-tramp-syntax) 'default) "[a-zA-Z0-9-]+")
+ ((eq (tramp-compat-tramp-syntax) 'simplified) "")
+ ((eq (tramp-compat-tramp-syntax) 'separate) "[a-zA-Z0-9-]*")
+ (t (error "Wrong `tramp-syntax' %s" tramp-syntax))))
(defun tramp-postfix-method-format ()
"String matching delimiter between method and user or host names.
On W32 systems, the volume letter must be ignored.")
(defconst tramp-completion-file-name-regexp-separate
- "\\`/\\[\\([^]]*\\)?\\'"
+ "\\`/\\[[^]]*\\'"
"Value for `tramp-completion-file-name-regexp' for separate remoting.
See `tramp-file-name-structure' for more explanations.")
;; Method, host name and user name completion.
;; `tramp-completion-dissect-file-name' returns a list of
-;; tramp-file-name structures. For all of them we return possible completions.
+;; tramp-file-name structures. For all of them we return possible completions.
(defun tramp-completion-handle-file-name-all-completions (filename directory)
"Like `file-name-all-completions' for partial Tramp files."
(file-remote-p "/user@host#1234:" 'localname) ""))
(should (string-equal (file-remote-p "/user@host#1234:" 'hop) nil))
- ;; Expand `tramp-default-method' and `tramp-default-user'.
+ ;; Expand `tramp-default-method' and `tramp-default-user'.
(should (string-equal
(file-remote-p "/1.2.3.4:")
(format "/%s@%s:" "default-user" "1.2.3.4")))
(should (string-equal (file-remote-p "/[method/]" 'localname) ""))
(should (string-equal (file-remote-p "/[method/]" 'hop) nil))
+ ;; Expand `tramp-default-method' and `tramp-default-user'.
+ (should (string-equal
+ (file-remote-p "/[/host]")
+ (format
+ "/[%s/%s@%s]" "default-method" "default-user" "host")))
+ (should (string-equal
+ (file-remote-p "/[/host]" 'method) "default-method"))
+ (should (string-equal
+ (file-remote-p "/[/host]" 'user) "default-user"))
+ (should (string-equal (file-remote-p "/[/host]" 'host) "host"))
+ (should (string-equal (file-remote-p "/[/host]" 'localname) ""))
+ (should (string-equal (file-remote-p "/[/host]" 'hop) nil))
+
+ ;; Expand `tramp-default-method' and `tramp-default-host'.
+ (should (string-equal
+ (file-remote-p "/[/user@]")
+ (format
+ "/[%s/%s@%s]" "default-method" "user" "default-host")))
+ (should (string-equal
+ (file-remote-p "/[/user@]" 'method) "default-method"))
+ (should (string-equal (file-remote-p "/[/user@]" 'user) "user"))
+ (should (string-equal
+ (file-remote-p "/[/user@]" 'host) "default-host"))
+ (should (string-equal (file-remote-p "/[/user@]" 'localname) ""))
+ (should (string-equal (file-remote-p "/[/user@]" 'hop) nil))
+
+ ;; Expand `tramp-default-method'.
+ (should (string-equal
+ (file-remote-p "/[/user@host]")
+ (format "/[%s/%s@%s]" "default-method" "user" "host")))
+ (should (string-equal
+ (file-remote-p "/[/user@host]" 'method) "default-method"))
+ (should (string-equal (file-remote-p "/[/user@host]" 'user) "user"))
+ (should (string-equal (file-remote-p "/[/user@host]" 'host) "host"))
+ (should (string-equal (file-remote-p "/[/user@host]" 'localname) ""))
+ (should (string-equal (file-remote-p "/[/user@host]" 'hop) nil))
+
;; Expand `tramp-default-method' and `tramp-default-user'.
(should (string-equal
(file-remote-p "/[-/host]")
(should (string-equal
(file-remote-p "/[method/user@email@host]" 'hop) nil))
+ ;; Expand `tramp-default-method' and `tramp-default-user'.
+ (should (string-equal
+ (file-remote-p "/[/host#1234]")
+ (format
+ "/[%s/%s@%s]" "default-method" "default-user" "host#1234")))
+ (should (string-equal
+ (file-remote-p "/[/host#1234]" 'method) "default-method"))
+ (should (string-equal
+ (file-remote-p "/[/host#1234]" 'user) "default-user"))
+ (should (string-equal
+ (file-remote-p "/[/host#1234]" 'host) "host#1234"))
+ (should (string-equal (file-remote-p "/[/host#1234]" 'localname) ""))
+ (should (string-equal (file-remote-p "/[/host#1234]" 'hop) nil))
+
+ ;; Expand `tramp-default-method'.
+ (should (string-equal
+ (file-remote-p "/[/user@host#1234]")
+ (format "/[%s/%s@%s]" "default-method" "user" "host#1234")))
+ (should (string-equal
+ (file-remote-p
+ "/[/user@host#1234]" 'method) "default-method"))
+ (should (string-equal
+ (file-remote-p
+ "/[/user@host#1234]" 'user) "user"))
+ (should (string-equal
+ (file-remote-p "/[/user@host#1234]" 'host) "host#1234"))
+ (should (string-equal
+ (file-remote-p "/[/user@host#1234]" 'localname) ""))
+ (should (string-equal (file-remote-p "/[/user@host#1234]" 'hop) nil))
+
;; Expand `tramp-default-method' and `tramp-default-user'.
(should (string-equal
(file-remote-p "/[-/host#1234]")
(should (string-equal
(file-remote-p "/[method/user@host#1234]" 'hop) nil))
+ ;; Expand `tramp-default-method' and `tramp-default-user'.
+ (should (string-equal
+ (file-remote-p "/[/1.2.3.4]")
+ (format
+ "/[%s/%s@%s]" "default-method" "default-user" "1.2.3.4")))
+ (should (string-equal
+ (file-remote-p "/[/1.2.3.4]" 'method) "default-method"))
+ (should (string-equal
+ (file-remote-p "/[/1.2.3.4]" 'user) "default-user"))
+ (should (string-equal
+ (file-remote-p "/[/1.2.3.4]" 'host) "1.2.3.4"))
+ (should (string-equal (file-remote-p "/[/1.2.3.4]" 'localname) ""))
+ (should (string-equal (file-remote-p "/[/1.2.3.4]" 'hop) nil))
+
+ ;; Expand `tramp-default-method'.
+ (should (string-equal
+ (file-remote-p "/[/user@1.2.3.4]")
+ (format "/[%s/%s@%s]" "default-method" "user" "1.2.3.4")))
+ (should (string-equal
+ (file-remote-p
+ "/[/user@1.2.3.4]" 'method) "default-method"))
+ (should (string-equal
+ (file-remote-p "/[/user@1.2.3.4]" 'user) "user"))
+ (should (string-equal
+ (file-remote-p "/[/user@1.2.3.4]" 'host) "1.2.3.4"))
+ (should (string-equal
+ (file-remote-p "/[/user@1.2.3.4]" 'localname) ""))
+ (should (string-equal (file-remote-p "/[/user@1.2.3.4]" 'hop) nil))
+
;; Expand `tramp-default-method' and `tramp-default-user'.
(should (string-equal
(file-remote-p "/[-/1.2.3.4]")
(should (string-equal
(file-remote-p "/[method/user@1.2.3.4]" 'hop) nil))
+ ;; Expand `tramp-default-method', `tramp-default-user' and
+ ;; `tramp-default-host'.
+ (should (string-equal
+ (file-remote-p "/[/]")
+ (format
+ "/[%s/%s@%s]"
+ "default-method" "default-user" "default-host")))
+ (should (string-equal
+ (file-remote-p "/[/]" 'method) "default-method"))
+ (should (string-equal (file-remote-p "/[/]" 'user) "default-user"))
+ (should (string-equal (file-remote-p "/[/]" 'host) "default-host"))
+ (should (string-equal (file-remote-p "/[/]" 'localname) ""))
+ (should (string-equal (file-remote-p "/[/]" 'hop) nil))
+
+ ;; Expand `tramp-default-method' and `tramp-default-user'.
+ (let ((tramp-default-host "::1"))
+ (should (string-equal
+ (file-remote-p "/[/]")
+ (format
+ "/[%s/%s@%s]"
+ "default-method" "default-user" "::1")))
+ (should (string-equal
+ (file-remote-p "/[/]" 'method) "default-method"))
+ (should (string-equal (file-remote-p "/[/]" 'user) "default-user"))
+ (should (string-equal (file-remote-p "/[/]" 'host) "::1"))
+ (should (string-equal (file-remote-p "/[/]" 'localname) ""))
+ (should (string-equal (file-remote-p "/[/]" 'hop) nil)))
+
+ ;; Expand `tramp-default-method' and `tramp-default-user'.
+ (should (string-equal
+ (file-remote-p "/[/::1]")
+ (format
+ "/[%s/%s@%s]" "default-method" "default-user" "::1")))
+ (should (string-equal
+ (file-remote-p "/[/::1]" 'method) "default-method"))
+ (should (string-equal
+ (file-remote-p "/[/::1]" 'user) "default-user"))
+ (should (string-equal (file-remote-p "/[/::1]" 'host) "::1"))
+ (should (string-equal (file-remote-p "/[/::1]" 'localname) ""))
+ (should (string-equal (file-remote-p "/[/::1]" 'hop) nil))
+
+ ;; Expand `tramp-default-method'.
+ (should (string-equal
+ (file-remote-p "/[/user@::1]")
+ (format "/[%s/%s@%s]" "default-method" "user" "::1")))
+ (should (string-equal
+ (file-remote-p "/[/user@::1]" 'method) "default-method"))
+ (should (string-equal (file-remote-p "/[/user@::1]" 'user) "user"))
+ (should (string-equal (file-remote-p "/[/user@::1]" 'host) "::1"))
+ (should (string-equal (file-remote-p "/[/user@::1]" 'localname) ""))
+ (should (string-equal (file-remote-p "/[/user@::1]" 'hop) nil))
+
;; Expand `tramp-default-method', `tramp-default-user' and
;; `tramp-default-host'.
(should (string-equal
(should (string-equal (file-remote-p "/[method/user@::1]" '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/]:" 'localname) ":"))
(should (string-equal (file-remote-p "/[method/] " 'localname) " "))