]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix error in completion for separate Tramp syntax
authorMichael Albinus <michael.albinus@gmx.de>
Tue, 2 May 2017 14:30:55 +0000 (16:30 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Tue, 2 May 2017 14:30:55 +0000 (16:30 +0200)
* lisp/net/tramp.el (tramp-completion-file-name-regexp-separate):
Tweak regexp.

* test/lisp/net/tramp-tests.el (tramp-test24-file-name-completion):
Run method and host name completion for all syntaxes.

lisp/net/tramp.el
test/lisp/net/tramp-tests.el

index 56a7b377124e97a634ed5352f5f17851f4aa9105..33e5900f3c28ad4a864294126cbef77392c10f4a 100644 (file)
@@ -945,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.")
 
index 1d487bc12d7a9705b632ad5c68ec707393f0b566..8db54979b6d4fee9ef3b3e5f413ffe0599729064 100644 (file)
@@ -2448,37 +2448,66 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
   "Check `file-name-completion' and `file-name-all-completions'."
   (skip-unless (tramp--test-enabled))
 
+  ;; Method and host name in completion mode.  This kind of completion
+  ;; does not work on MS Windows.
+  (when (not (memq system-type '(cygwin windows-nt)))
+    (let ((method (file-remote-p tramp-test-temporary-file-directory 'method))
+         (host (file-remote-p tramp-test-temporary-file-directory 'host))
+          (orig-syntax tramp-syntax))
+
+      (unwind-protect
+          (dolist (syntax (tramp-syntax-values))
+            (tramp-change-syntax syntax)
+            (let ;; This is needed for the `simplified' syntax.
+                ((method-marker
+                  (if (zerop (length (tramp-method-regexp)))
+                      "" tramp-default-method-marker))
+                 ;; This is needed for the `separate' syntax.
+                 (prefix-format (substring (tramp-prefix-format) 1)))
+              ;; Complete method name.
+             (unless (or (zerop (length method))
+                          (zerop (length (tramp-method-regexp))))
+               (should
+                (member
+                 (concat prefix-format method (tramp-postfix-method-format))
+                 (file-name-all-completions
+                   (concat prefix-format (substring method 0 1)) "/"))))
+              ;; Complete host name for default method.
+             (unless (zerop (length host))
+               (let ((tramp-default-method (or method tramp-default-method)))
+                 (should
+                  (member
+                   (concat
+                     prefix-format method-marker (tramp-postfix-method-format)
+                     host (tramp-postfix-host-format))
+                   (file-name-all-completions
+                    (concat
+                      prefix-format method-marker (tramp-postfix-method-format)
+                      (substring host 0 1))
+                     "/")))))
+              ;; Complete host name.
+             (unless (or (zerop (length method))
+                          (zerop (length (tramp-method-regexp)))
+                          (zerop (length host)))
+               (should
+                (member
+                 (concat
+                   prefix-format method (tramp-postfix-method-format)
+                   host (tramp-postfix-host-format))
+                 (file-name-all-completions
+                  (concat prefix-format method (tramp-postfix-method-format))
+                   "/"))))))
+
+       ;; Cleanup.
+        (tramp-change-syntax orig-syntax))))
+
   (dolist (n-e '(nil t))
     (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil)))
       (let ((non-essential n-e)
-           (tmp-name (tramp--test-make-temp-name nil quoted))
-           (method (file-remote-p tramp-test-temporary-file-directory 'method))
-           (host (file-remote-p tramp-test-temporary-file-directory 'host)))
+           (tmp-name (tramp--test-make-temp-name nil quoted)))
 
        (unwind-protect
            (progn
-             ;; Method and host name in completion mode.  This kind
-             ;; of completion does not work on MS Windows.
-             (when (not (memq system-type '(cygwin windows-nt)))
-               (unless (zerop (length method))
-                 (should
-                  (member
-                   (format "%s:" method)
-                   (file-name-all-completions (substring method 0 1) "/"))))
-               (unless (zerop (length host))
-                 (let ((tramp-default-method (or method tramp-default-method)))
-                   (should
-                    (member
-                     (format "-:%s:" host)
-                     (file-name-all-completions
-                      (format "-:%s" (substring host 0 1)) "/")))))
-               (unless (or (zerop (length method)) (zerop (length host)))
-                 (should
-                  (member
-                   (format "%s:%s:" method host)
-                   (file-name-all-completions
-                    (format "%s:" method) "/")))))
-
              ;; Local files.
              (make-directory tmp-name)
              (should (file-directory-p tmp-name))