From: Michael Albinus Date: Sun, 16 Apr 2017 14:51:24 +0000 (+0200) Subject: Tuning for `separate' Tramp syntax X-Git-Tag: emacs-26.0.90~521^2~619 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8d96feae07c618f591a952f8f10ae949735b4050;p=emacs.git 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. --- 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"))) @@ -959,6 +959,43 @@ handled properly. BODY shall not contain a timeout." (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]") @@ -1053,6 +1090,36 @@ handled properly. BODY shall not contain a timeout." (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]") @@ -1113,6 +1180,35 @@ handled properly. BODY shall not contain a timeout." (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]") @@ -1171,6 +1267,58 @@ handled properly. BODY shall not contain a timeout." (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 @@ -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) " "))