From b50dda3fa2d21973cd87b537a746f5ed70bdc9af Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Tue, 2 May 2017 16:30:55 +0200 Subject: [PATCH] Fix error in completion for separate Tramp syntax * 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 | 2 +- test/lisp/net/tramp-tests.el | 79 ++++++++++++++++++++++++------------ 2 files changed, 55 insertions(+), 26 deletions(-) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 56a7b377124..33e5900f3c2 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -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.") diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 1d487bc12d7..8db54979b6d 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -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)) -- 2.39.5