1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-25 23:10:47 -08:00

Fix file name completion with Tramp on MS Windoes

* doc/misc/trampver.texi:
* lisp/net/trampver.el (tramp-version): Adapt Tramp versions.

* lisp/net/tramp.el (tramp-build-completion-file-name-regexp):
Do not use `tramp-volume-letter-regexp'.  (Bug#68320)
(tramp-completion-handle-expand-file-name): Simplify regexp.

* test/lisp/net/tramp-tests.el (tramp-test26-file-name-completion)
(tramp-test26-interactive-file-name-completion): Run also on MS Windows.
This commit is contained in:
Michael Albinus 2024-01-10 12:49:08 +01:00
parent eb913c7501
commit cf887b7eb0
4 changed files with 53 additions and 64 deletions

View file

@ -7,7 +7,7 @@
@c In the Tramp GIT, the version number and the bug report address @c In the Tramp GIT, the version number and the bug report address
@c are auto-frobbed from configure.ac. @c are auto-frobbed from configure.ac.
@set trampver 2.7.0 @set trampver 2.7.1-pre
@set trampurl https://www.gnu.org/software/tramp/ @set trampurl https://www.gnu.org/software/tramp/
@set tramp-bug-report-address tramp-devel@@gnu.org @set tramp-bug-report-address tramp-devel@@gnu.org
@set emacsver 27.1 @set emacsver 27.1

View file

@ -1205,14 +1205,7 @@ The `ftp' syntax does not support methods.")
;; FIXME: This shouldn't be necessary. ;; FIXME: This shouldn't be necessary.
(rx bos "/" (? "[" (* (not "]"))) eos) (rx bos "/" (? "[" (* (not "]"))) eos)
(rx (rx
bos (regexp tramp-prefix-regexp)
;; `file-name-completion' uses absolute paths for matching.
;; This means that on W32 systems, something like
;; "/ssh:host:~/path" becomes "c:/ssh:host:~/path". See also
;; `tramp-drop-volume-letter'.
(? (regexp tramp-volume-letter-regexp))
;; We cannot use `tramp-prefix-regexp', because it starts with `bol'.
(literal tramp-prefix-format)
;; Optional multi-hops. ;; Optional multi-hops.
(* (regexp tramp-remote-file-name-spec-regexp) (* (regexp tramp-remote-file-name-spec-regexp)
@ -2666,7 +2659,7 @@ not in completion mode."
(string-match-p (rx (regexp tramp-postfix-host-regexp) eos) dir)) (string-match-p (rx (regexp tramp-postfix-host-regexp) eos) dir))
(concat dir filename)) (concat dir filename))
((string-match-p ((string-match-p
(rx bos (regexp tramp-prefix-regexp) (rx (regexp tramp-prefix-regexp)
(* (regexp tramp-remote-file-name-spec-regexp) (* (regexp tramp-remote-file-name-spec-regexp)
(regexp tramp-postfix-hop-regexp)) (regexp tramp-postfix-hop-regexp))
(? (regexp tramp-method-regexp) (regexp tramp-postfix-method-regexp) (? (regexp tramp-method-regexp) (regexp tramp-postfix-method-regexp)

View file

@ -7,7 +7,7 @@
;; Maintainer: Michael Albinus <michael.albinus@gmx.de> ;; Maintainer: Michael Albinus <michael.albinus@gmx.de>
;; Keywords: comm, processes ;; Keywords: comm, processes
;; Package: tramp ;; Package: tramp
;; Version: 2.7.0 ;; Version: 2.7.1-pre
;; Package-Requires: ((emacs "27.1")) ;; Package-Requires: ((emacs "27.1"))
;; Package-Type: multi ;; Package-Type: multi
;; URL: https://www.gnu.org/software/tramp/ ;; URL: https://www.gnu.org/software/tramp/
@ -40,7 +40,7 @@
;; ./configure" to change them. ;; ./configure" to change them.
;;;###tramp-autoload ;;;###tramp-autoload
(defconst tramp-version "2.7.0" (defconst tramp-version "2.7.1-pre"
"This version of Tramp.") "This version of Tramp.")
;;;###tramp-autoload ;;;###tramp-autoload
@ -78,7 +78,7 @@
;; Check for Emacs version. ;; Check for Emacs version.
(let ((x (if (not (string-version-lessp emacs-version "27.1")) (let ((x (if (not (string-version-lessp emacs-version "27.1"))
"ok" "ok"
(format "Tramp 2.7.0 is not fit for %s" (format "Tramp 2.7.1-pre is not fit for %s"
(replace-regexp-in-string "\n" "" (emacs-version)))))) (replace-regexp-in-string "\n" "" (emacs-version))))))
(unless (string-equal "ok" x) (error "%s" x))) (unless (string-equal "ok" x) (error "%s" x)))

View file

@ -4719,57 +4719,55 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
"Check `file-name-completion' and `file-name-all-completions'." "Check `file-name-completion' and `file-name-all-completions'."
(skip-unless (tramp--test-enabled)) (skip-unless (tramp--test-enabled))
;; Method and host name in completion mode. This kind of completion ;; Method and host name in completion mode.
;; does not work on MS Windows. (let ((tramp-fuse-remove-hidden-files t)
(unless (memq system-type '(cygwin windows-nt)) (method (file-remote-p ert-remote-temporary-file-directory 'method))
(let ((tramp-fuse-remove-hidden-files t) (host (file-remote-p ert-remote-temporary-file-directory 'host))
(method (file-remote-p ert-remote-temporary-file-directory 'method)) (orig-syntax tramp-syntax)
(host (file-remote-p ert-remote-temporary-file-directory 'host)) (minibuffer-completing-file-name t))
(orig-syntax tramp-syntax) (when (and (stringp host) (string-match tramp-host-with-port-regexp host))
(minibuffer-completing-file-name t)) (setq host (match-string 1 host)))
(when (and (stringp host) (string-match tramp-host-with-port-regexp host))
(setq host (match-string 1 host)))
(unwind-protect (unwind-protect
(dolist (syntax (if (tramp--test-expensive-test-p) (dolist (syntax (if (tramp--test-expensive-test-p)
(tramp-syntax-values) `(,orig-syntax))) (tramp-syntax-values) `(,orig-syntax)))
(tramp-change-syntax syntax) (tramp-change-syntax syntax)
;; This has cleaned up all connection data, which are used ;; This has cleaned up all connection data, which are used
;; for completion. We must refill the cache. ;; for completion. We must refill the cache.
(tramp-set-connection-property tramp-test-vec "property" nil) (tramp-set-connection-property tramp-test-vec "property" nil)
(let (;; This is needed for the `separate' syntax. (let (;; This is needed for the `separate' syntax.
(prefix-format (substring tramp-prefix-format 1)) (prefix-format (substring tramp-prefix-format 1))
;; This is needed for the IPv6 host name syntax. ;; This is needed for the IPv6 host name syntax.
(ipv6-prefix (ipv6-prefix
(and (string-match-p tramp-ipv6-regexp host) (and (string-match-p tramp-ipv6-regexp host)
tramp-prefix-ipv6-format)) tramp-prefix-ipv6-format))
(ipv6-postfix (ipv6-postfix
(and (string-match-p tramp-ipv6-regexp host) (and (string-match-p tramp-ipv6-regexp host)
tramp-postfix-ipv6-format))) tramp-postfix-ipv6-format)))
;; Complete method name. ;; Complete method name.
(unless (or (tramp-string-empty-or-nil-p method) (unless (or (tramp-string-empty-or-nil-p method)
(string-empty-p tramp-method-regexp)) (string-empty-p tramp-method-regexp))
(should (should
(member (member
(concat prefix-format method tramp-postfix-method-format) (concat prefix-format method tramp-postfix-method-format)
(file-name-all-completions (file-name-all-completions
(concat prefix-format (substring method 0 1)) "/")))) (concat prefix-format (substring method 0 1)) "/"))))
;; Complete host name. ;; Complete host name.
(unless (or (tramp-string-empty-or-nil-p method) (unless (or (tramp-string-empty-or-nil-p method)
(string-empty-p tramp-method-regexp) (string-empty-p tramp-method-regexp)
(tramp-string-empty-or-nil-p host)) (tramp-string-empty-or-nil-p host))
(should (should
(member (member
(concat (concat
prefix-format method tramp-postfix-method-format prefix-format method tramp-postfix-method-format
ipv6-prefix host ipv6-postfix tramp-postfix-host-format) ipv6-prefix host ipv6-postfix tramp-postfix-host-format)
(file-name-all-completions (file-name-all-completions
(concat prefix-format method tramp-postfix-method-format) (concat prefix-format method tramp-postfix-method-format)
"/")))))) "/"))))))
;; Cleanup. ;; Cleanup.
(tramp-change-syntax orig-syntax)))) (tramp-change-syntax orig-syntax)))
(dolist (non-essential '(nil t)) (dolist (non-essential '(nil t))
(dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil))) (dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil)))
@ -4851,9 +4849,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
;; and Bug#60505. ;; and Bug#60505.
(ert-deftest tramp-test26-interactive-file-name-completion () (ert-deftest tramp-test26-interactive-file-name-completion ()
"Check interactive completion with different `completion-styles'." "Check interactive completion with different `completion-styles'."
;; Method, user and host name in completion mode. This kind of ;; Method, user and host name in completion mode.
;; completion does not work on MS Windows.
(skip-unless (not (memq system-type '(cygwin windows-nt))))
(tramp-cleanup-connection tramp-test-vec nil 'keep-password) (tramp-cleanup-connection tramp-test-vec nil 'keep-password)
(let ((method (file-remote-p ert-remote-temporary-file-directory 'method)) (let ((method (file-remote-p ert-remote-temporary-file-directory 'method))