summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2017-04-16 16:51:24 +0200
committerMichael Albinus <michael.albinus@gmx.de>2017-04-16 16:51:24 +0200
commit8d96feae07c618f591a952f8f10ae949735b4050 (patch)
tree4ccdd07d64cd843af9881cb79cc1a69a1c7b365c
parent92879a1b035baf297158812ccdbaf6ae1d157e16 (diff)
downloademacs-8d96feae07c618f591a952f8f10ae949735b4050.tar.gz
Tuning for `separate' Tramp syntax
* lisp/net/tramp.el (tramp-method-regexp): Fix it for `separate' syntax. (tramp-completion-file-name-regexp-separate): Simplify. * test/lisp/net/tramp-tests.el (tramp-test02-file-name-dissect-separate): Extend test.
-rw-r--r--lisp/net/tramp.el9
-rw-r--r--test/lisp/net/tramp-tests.el151
2 files changed, 156 insertions, 4 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 12169d473e4..9b80c596a3a 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -717,7 +717,10 @@ Should always start with \"^\". Derived from `tramp-prefix-format'."
(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.
@@ -942,7 +945,7 @@ See `tramp-file-name-structure' for more explanations.
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.")
@@ -2306,7 +2309,7 @@ not in completion mode."
;; 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."
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 9dcb3ec9767..1d487bc12d7 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -764,7 +764,7 @@ handled properly. BODY shall not contain a timeout."
(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")))
@@ -961,6 +961,43 @@ handled properly. BODY shall not contain a timeout."
;; 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]")
(format
"/[%s/%s@%s]" "default-method" "default-user" "host")))
@@ -1055,6 +1092,36 @@ handled properly. BODY shall not contain a timeout."
;; 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]")
(format
"/[%s/%s@%s]" "default-method" "default-user" "host#1234")))
@@ -1115,6 +1182,35 @@ handled properly. BODY shall not contain a timeout."
;; 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]")
(format
"/[%s/%s@%s]" "default-method" "default-user" "1.2.3.4")))
@@ -1174,6 +1270,58 @@ handled properly. BODY shall not contain a timeout."
;; 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
(file-remote-p "/[-/]")
(format
"/[%s/%s@%s]"
@@ -1250,6 +1398,7 @@ handled properly. BODY shall not contain a timeout."
(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) " "))