diff options
| author | Michael Albinus | 2017-04-16 16:51:24 +0200 |
|---|---|---|
| committer | Michael Albinus | 2017-04-16 16:51:24 +0200 |
| commit | 8d96feae07c618f591a952f8f10ae949735b4050 (patch) | |
| tree | 4ccdd07d64cd843af9881cb79cc1a69a1c7b365c | |
| parent | 92879a1b035baf297158812ccdbaf6ae1d157e16 (diff) | |
| download | emacs-8d96feae07c618f591a952f8f10ae949735b4050.tar.gz emacs-8d96feae07c618f591a952f8f10ae949735b4050.zip | |
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.el | 9 | ||||
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 151 |
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'." | |||
| 717 | (defun tramp-method-regexp () | 717 | (defun tramp-method-regexp () |
| 718 | "Regexp matching methods identifiers. | 718 | "Regexp matching methods identifiers. |
| 719 | The `ftp' syntax does not support methods." | 719 | The `ftp' syntax does not support methods." |
| 720 | (if (eq (tramp-compat-tramp-syntax) 'simplified) "" "[a-zA-Z0-9-]+")) | 720 | (cond ((eq (tramp-compat-tramp-syntax) 'default) "[a-zA-Z0-9-]+") |
| 721 | ((eq (tramp-compat-tramp-syntax) 'simplified) "") | ||
| 722 | ((eq (tramp-compat-tramp-syntax) 'separate) "[a-zA-Z0-9-]*") | ||
| 723 | (t (error "Wrong `tramp-syntax' %s" tramp-syntax)))) | ||
| 721 | 724 | ||
| 722 | (defun tramp-postfix-method-format () | 725 | (defun tramp-postfix-method-format () |
| 723 | "String matching delimiter between method and user or host names. | 726 | "String matching delimiter between method and user or host names. |
| @@ -942,7 +945,7 @@ See `tramp-file-name-structure' for more explanations. | |||
| 942 | On W32 systems, the volume letter must be ignored.") | 945 | On W32 systems, the volume letter must be ignored.") |
| 943 | 946 | ||
| 944 | (defconst tramp-completion-file-name-regexp-separate | 947 | (defconst tramp-completion-file-name-regexp-separate |
| 945 | "\\`/\\[\\([^]]*\\)?\\'" | 948 | "\\`/\\[[^]]*\\'" |
| 946 | "Value for `tramp-completion-file-name-regexp' for separate remoting. | 949 | "Value for `tramp-completion-file-name-regexp' for separate remoting. |
| 947 | See `tramp-file-name-structure' for more explanations.") | 950 | See `tramp-file-name-structure' for more explanations.") |
| 948 | 951 | ||
| @@ -2306,7 +2309,7 @@ not in completion mode." | |||
| 2306 | 2309 | ||
| 2307 | ;; Method, host name and user name completion. | 2310 | ;; Method, host name and user name completion. |
| 2308 | ;; `tramp-completion-dissect-file-name' returns a list of | 2311 | ;; `tramp-completion-dissect-file-name' returns a list of |
| 2309 | ;; tramp-file-name structures. For all of them we return possible completions. | 2312 | ;; tramp-file-name structures. For all of them we return possible completions. |
| 2310 | (defun tramp-completion-handle-file-name-all-completions (filename directory) | 2313 | (defun tramp-completion-handle-file-name-all-completions (filename directory) |
| 2311 | "Like `file-name-all-completions' for partial Tramp files." | 2314 | "Like `file-name-all-completions' for partial Tramp files." |
| 2312 | 2315 | ||
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." | |||
| 764 | (file-remote-p "/user@host#1234:" 'localname) "")) | 764 | (file-remote-p "/user@host#1234:" 'localname) "")) |
| 765 | (should (string-equal (file-remote-p "/user@host#1234:" 'hop) nil)) | 765 | (should (string-equal (file-remote-p "/user@host#1234:" 'hop) nil)) |
| 766 | 766 | ||
| 767 | ;; Expand `tramp-default-method' and `tramp-default-user'. | 767 | ;; Expand `tramp-default-method' and `tramp-default-user'. |
| 768 | (should (string-equal | 768 | (should (string-equal |
| 769 | (file-remote-p "/1.2.3.4:") | 769 | (file-remote-p "/1.2.3.4:") |
| 770 | (format "/%s@%s:" "default-user" "1.2.3.4"))) | 770 | (format "/%s@%s:" "default-user" "1.2.3.4"))) |
| @@ -961,6 +961,43 @@ handled properly. BODY shall not contain a timeout." | |||
| 961 | 961 | ||
| 962 | ;; Expand `tramp-default-method' and `tramp-default-user'. | 962 | ;; Expand `tramp-default-method' and `tramp-default-user'. |
| 963 | (should (string-equal | 963 | (should (string-equal |
| 964 | (file-remote-p "/[/host]") | ||
| 965 | (format | ||
| 966 | "/[%s/%s@%s]" "default-method" "default-user" "host"))) | ||
| 967 | (should (string-equal | ||
| 968 | (file-remote-p "/[/host]" 'method) "default-method")) | ||
| 969 | (should (string-equal | ||
| 970 | (file-remote-p "/[/host]" 'user) "default-user")) | ||
| 971 | (should (string-equal (file-remote-p "/[/host]" 'host) "host")) | ||
| 972 | (should (string-equal (file-remote-p "/[/host]" 'localname) "")) | ||
| 973 | (should (string-equal (file-remote-p "/[/host]" 'hop) nil)) | ||
| 974 | |||
| 975 | ;; Expand `tramp-default-method' and `tramp-default-host'. | ||
| 976 | (should (string-equal | ||
| 977 | (file-remote-p "/[/user@]") | ||
| 978 | (format | ||
| 979 | "/[%s/%s@%s]" "default-method" "user" "default-host"))) | ||
| 980 | (should (string-equal | ||
| 981 | (file-remote-p "/[/user@]" 'method) "default-method")) | ||
| 982 | (should (string-equal (file-remote-p "/[/user@]" 'user) "user")) | ||
| 983 | (should (string-equal | ||
| 984 | (file-remote-p "/[/user@]" 'host) "default-host")) | ||
| 985 | (should (string-equal (file-remote-p "/[/user@]" 'localname) "")) | ||
| 986 | (should (string-equal (file-remote-p "/[/user@]" 'hop) nil)) | ||
| 987 | |||
| 988 | ;; Expand `tramp-default-method'. | ||
| 989 | (should (string-equal | ||
| 990 | (file-remote-p "/[/user@host]") | ||
| 991 | (format "/[%s/%s@%s]" "default-method" "user" "host"))) | ||
| 992 | (should (string-equal | ||
| 993 | (file-remote-p "/[/user@host]" 'method) "default-method")) | ||
| 994 | (should (string-equal (file-remote-p "/[/user@host]" 'user) "user")) | ||
| 995 | (should (string-equal (file-remote-p "/[/user@host]" 'host) "host")) | ||
| 996 | (should (string-equal (file-remote-p "/[/user@host]" 'localname) "")) | ||
| 997 | (should (string-equal (file-remote-p "/[/user@host]" 'hop) nil)) | ||
| 998 | |||
| 999 | ;; Expand `tramp-default-method' and `tramp-default-user'. | ||
| 1000 | (should (string-equal | ||
| 964 | (file-remote-p "/[-/host]") | 1001 | (file-remote-p "/[-/host]") |
| 965 | (format | 1002 | (format |
| 966 | "/[%s/%s@%s]" "default-method" "default-user" "host"))) | 1003 | "/[%s/%s@%s]" "default-method" "default-user" "host"))) |
| @@ -1055,6 +1092,36 @@ handled properly. BODY shall not contain a timeout." | |||
| 1055 | 1092 | ||
| 1056 | ;; Expand `tramp-default-method' and `tramp-default-user'. | 1093 | ;; Expand `tramp-default-method' and `tramp-default-user'. |
| 1057 | (should (string-equal | 1094 | (should (string-equal |
| 1095 | (file-remote-p "/[/host#1234]") | ||
| 1096 | (format | ||
| 1097 | "/[%s/%s@%s]" "default-method" "default-user" "host#1234"))) | ||
| 1098 | (should (string-equal | ||
| 1099 | (file-remote-p "/[/host#1234]" 'method) "default-method")) | ||
| 1100 | (should (string-equal | ||
| 1101 | (file-remote-p "/[/host#1234]" 'user) "default-user")) | ||
| 1102 | (should (string-equal | ||
| 1103 | (file-remote-p "/[/host#1234]" 'host) "host#1234")) | ||
| 1104 | (should (string-equal (file-remote-p "/[/host#1234]" 'localname) "")) | ||
| 1105 | (should (string-equal (file-remote-p "/[/host#1234]" 'hop) nil)) | ||
| 1106 | |||
| 1107 | ;; Expand `tramp-default-method'. | ||
| 1108 | (should (string-equal | ||
| 1109 | (file-remote-p "/[/user@host#1234]") | ||
| 1110 | (format "/[%s/%s@%s]" "default-method" "user" "host#1234"))) | ||
| 1111 | (should (string-equal | ||
| 1112 | (file-remote-p | ||
| 1113 | "/[/user@host#1234]" 'method) "default-method")) | ||
| 1114 | (should (string-equal | ||
| 1115 | (file-remote-p | ||
| 1116 | "/[/user@host#1234]" 'user) "user")) | ||
| 1117 | (should (string-equal | ||
| 1118 | (file-remote-p "/[/user@host#1234]" 'host) "host#1234")) | ||
| 1119 | (should (string-equal | ||
| 1120 | (file-remote-p "/[/user@host#1234]" 'localname) "")) | ||
| 1121 | (should (string-equal (file-remote-p "/[/user@host#1234]" 'hop) nil)) | ||
| 1122 | |||
| 1123 | ;; Expand `tramp-default-method' and `tramp-default-user'. | ||
| 1124 | (should (string-equal | ||
| 1058 | (file-remote-p "/[-/host#1234]") | 1125 | (file-remote-p "/[-/host#1234]") |
| 1059 | (format | 1126 | (format |
| 1060 | "/[%s/%s@%s]" "default-method" "default-user" "host#1234"))) | 1127 | "/[%s/%s@%s]" "default-method" "default-user" "host#1234"))) |
| @@ -1115,6 +1182,35 @@ handled properly. BODY shall not contain a timeout." | |||
| 1115 | 1182 | ||
| 1116 | ;; Expand `tramp-default-method' and `tramp-default-user'. | 1183 | ;; Expand `tramp-default-method' and `tramp-default-user'. |
| 1117 | (should (string-equal | 1184 | (should (string-equal |
| 1185 | (file-remote-p "/[/1.2.3.4]") | ||
| 1186 | (format | ||
| 1187 | "/[%s/%s@%s]" "default-method" "default-user" "1.2.3.4"))) | ||
| 1188 | (should (string-equal | ||
| 1189 | (file-remote-p "/[/1.2.3.4]" 'method) "default-method")) | ||
| 1190 | (should (string-equal | ||
| 1191 | (file-remote-p "/[/1.2.3.4]" 'user) "default-user")) | ||
| 1192 | (should (string-equal | ||
| 1193 | (file-remote-p "/[/1.2.3.4]" 'host) "1.2.3.4")) | ||
| 1194 | (should (string-equal (file-remote-p "/[/1.2.3.4]" 'localname) "")) | ||
| 1195 | (should (string-equal (file-remote-p "/[/1.2.3.4]" 'hop) nil)) | ||
| 1196 | |||
| 1197 | ;; Expand `tramp-default-method'. | ||
| 1198 | (should (string-equal | ||
| 1199 | (file-remote-p "/[/user@1.2.3.4]") | ||
| 1200 | (format "/[%s/%s@%s]" "default-method" "user" "1.2.3.4"))) | ||
| 1201 | (should (string-equal | ||
| 1202 | (file-remote-p | ||
| 1203 | "/[/user@1.2.3.4]" 'method) "default-method")) | ||
| 1204 | (should (string-equal | ||
| 1205 | (file-remote-p "/[/user@1.2.3.4]" 'user) "user")) | ||
| 1206 | (should (string-equal | ||
| 1207 | (file-remote-p "/[/user@1.2.3.4]" 'host) "1.2.3.4")) | ||
| 1208 | (should (string-equal | ||
| 1209 | (file-remote-p "/[/user@1.2.3.4]" 'localname) "")) | ||
| 1210 | (should (string-equal (file-remote-p "/[/user@1.2.3.4]" 'hop) nil)) | ||
| 1211 | |||
| 1212 | ;; Expand `tramp-default-method' and `tramp-default-user'. | ||
| 1213 | (should (string-equal | ||
| 1118 | (file-remote-p "/[-/1.2.3.4]") | 1214 | (file-remote-p "/[-/1.2.3.4]") |
| 1119 | (format | 1215 | (format |
| 1120 | "/[%s/%s@%s]" "default-method" "default-user" "1.2.3.4"))) | 1216 | "/[%s/%s@%s]" "default-method" "default-user" "1.2.3.4"))) |
| @@ -1174,6 +1270,58 @@ handled properly. BODY shall not contain a timeout." | |||
| 1174 | ;; Expand `tramp-default-method', `tramp-default-user' and | 1270 | ;; Expand `tramp-default-method', `tramp-default-user' and |
| 1175 | ;; `tramp-default-host'. | 1271 | ;; `tramp-default-host'. |
| 1176 | (should (string-equal | 1272 | (should (string-equal |
| 1273 | (file-remote-p "/[/]") | ||
| 1274 | (format | ||
| 1275 | "/[%s/%s@%s]" | ||
| 1276 | "default-method" "default-user" "default-host"))) | ||
| 1277 | (should (string-equal | ||
| 1278 | (file-remote-p "/[/]" 'method) "default-method")) | ||
| 1279 | (should (string-equal (file-remote-p "/[/]" 'user) "default-user")) | ||
| 1280 | (should (string-equal (file-remote-p "/[/]" 'host) "default-host")) | ||
| 1281 | (should (string-equal (file-remote-p "/[/]" 'localname) "")) | ||
| 1282 | (should (string-equal (file-remote-p "/[/]" 'hop) nil)) | ||
| 1283 | |||
| 1284 | ;; Expand `tramp-default-method' and `tramp-default-user'. | ||
| 1285 | (let ((tramp-default-host "::1")) | ||
| 1286 | (should (string-equal | ||
| 1287 | (file-remote-p "/[/]") | ||
| 1288 | (format | ||
| 1289 | "/[%s/%s@%s]" | ||
| 1290 | "default-method" "default-user" "::1"))) | ||
| 1291 | (should (string-equal | ||
| 1292 | (file-remote-p "/[/]" 'method) "default-method")) | ||
| 1293 | (should (string-equal (file-remote-p "/[/]" 'user) "default-user")) | ||
| 1294 | (should (string-equal (file-remote-p "/[/]" 'host) "::1")) | ||
| 1295 | (should (string-equal (file-remote-p "/[/]" 'localname) "")) | ||
| 1296 | (should (string-equal (file-remote-p "/[/]" 'hop) nil))) | ||
| 1297 | |||
| 1298 | ;; Expand `tramp-default-method' and `tramp-default-user'. | ||
| 1299 | (should (string-equal | ||
| 1300 | (file-remote-p "/[/::1]") | ||
| 1301 | (format | ||
| 1302 | "/[%s/%s@%s]" "default-method" "default-user" "::1"))) | ||
| 1303 | (should (string-equal | ||
| 1304 | (file-remote-p "/[/::1]" 'method) "default-method")) | ||
| 1305 | (should (string-equal | ||
| 1306 | (file-remote-p "/[/::1]" 'user) "default-user")) | ||
| 1307 | (should (string-equal (file-remote-p "/[/::1]" 'host) "::1")) | ||
| 1308 | (should (string-equal (file-remote-p "/[/::1]" 'localname) "")) | ||
| 1309 | (should (string-equal (file-remote-p "/[/::1]" 'hop) nil)) | ||
| 1310 | |||
| 1311 | ;; Expand `tramp-default-method'. | ||
| 1312 | (should (string-equal | ||
| 1313 | (file-remote-p "/[/user@::1]") | ||
| 1314 | (format "/[%s/%s@%s]" "default-method" "user" "::1"))) | ||
| 1315 | (should (string-equal | ||
| 1316 | (file-remote-p "/[/user@::1]" 'method) "default-method")) | ||
| 1317 | (should (string-equal (file-remote-p "/[/user@::1]" 'user) "user")) | ||
| 1318 | (should (string-equal (file-remote-p "/[/user@::1]" 'host) "::1")) | ||
| 1319 | (should (string-equal (file-remote-p "/[/user@::1]" 'localname) "")) | ||
| 1320 | (should (string-equal (file-remote-p "/[/user@::1]" 'hop) nil)) | ||
| 1321 | |||
| 1322 | ;; Expand `tramp-default-method', `tramp-default-user' and | ||
| 1323 | ;; `tramp-default-host'. | ||
| 1324 | (should (string-equal | ||
| 1177 | (file-remote-p "/[-/]") | 1325 | (file-remote-p "/[-/]") |
| 1178 | (format | 1326 | (format |
| 1179 | "/[%s/%s@%s]" | 1327 | "/[%s/%s@%s]" |
| @@ -1250,6 +1398,7 @@ handled properly. BODY shall not contain a timeout." | |||
| 1250 | (should (string-equal (file-remote-p "/[method/user@::1]" 'hop) nil)) | 1398 | (should (string-equal (file-remote-p "/[method/user@::1]" 'hop) nil)) |
| 1251 | 1399 | ||
| 1252 | ;; Local file name part. | 1400 | ;; Local file name part. |
| 1401 | (should (string-equal (file-remote-p "/[/host]/:" 'localname) "/:")) | ||
| 1253 | (should (string-equal (file-remote-p "/[-/host]/:" 'localname) "/:")) | 1402 | (should (string-equal (file-remote-p "/[-/host]/:" 'localname) "/:")) |
| 1254 | (should (string-equal (file-remote-p "/[method/]:" 'localname) ":")) | 1403 | (should (string-equal (file-remote-p "/[method/]:" 'localname) ":")) |
| 1255 | (should (string-equal (file-remote-p "/[method/] " 'localname) " ")) | 1404 | (should (string-equal (file-remote-p "/[method/] " 'localname) " ")) |