Commit 70045452 authored by Michael Albinus's avatar Michael Albinus
Browse files

Further optimization in Tramp's file name decomposition

* lisp/net/tramp.el (tramp-syntax): Recompute all file name
components.  Call `custom-set-variables' after loading.
(tramp-build-prefix-format, tramp-build-prefix-regexp)
(tramp-build-method-regexp)
(tramp-build-postfix-method-format)
(tramp-build-postfix-method-regexp)
(tramp-build-prefix-ipv6-format)
(tramp-build-prefix-ipv6-regexp)
(tramp-build-postfix-ipv6-format)
(tramp-build-postfix-ipv6-regexp)
(tramp-build-postfix-host-format)
(tramp-build-postfix-host-regexp)
(tramp-build-file-name-regexp)
(tramp-build-completion-file-name-regexp): New defuns.
(tramp-prefix-format, tramp-prefix-regexp)
(tramp-method-regexp, tramp-postfix-method-format)
(tramp-postfix-method-regexp, tramp-prefix-ipv6-format)
(tramp-prefix-ipv6-regexp, tramp-postfix-ipv6-format)
(tramp-postfix-ipv6-regexp, tramp-postfix-host-format)
(tramp-postfix-host-regexp)
(tramp-remote-file-name-spec-regexp)
(tramp-file-name-structure, tramp-file-name-regexp)
(tramp-completion-file-name-regexp): Convert defuns into defvars.
(tramp-prefix-regexp-alist)
(tramp-postfix-method-regexp-alist)
(tramp-prefix-ipv6-regexp-alist)
(tramp-postfix-ipv6-regexp-alist)
(tramp-postfix-host-regexp-alist)
(tramp-remote-file-name-spec-regexp-alist): Remove.
(tramp-build-remote-file-name-spec-regexp)
(tramp-build-file-name-structure): Simplify.
(tramp-completion-file-name-regexp-alist): New defconst.
(tramp-tramp-file-p, tramp-dissect-file-name)
(tramp-make-tramp-file-name)
(tramp-completion-make-tramp-file-name)
(tramp-rfn-eshadow-update-overlay-regexp)
(tramp-register-file-name-handlers)
(tramp-completion-handle-file-name-all-completions)
(tramp-completion-dissect-file-name, tramp-clear-passwd):
* lisp/net/tramp-ftp.el (tramp-ftp-file-name-handler):
* lisp/net/tramp-sh.el (tramp-sh-handle-vc-registered)
(tramp-compute-multi-hops): Use variables but functions for
file name components.

* test/lisp/net/tramp-tests.el (tramp-test24-file-name-completion):
Use variables but functions for file name components.
parent 29963648
......@@ -121,10 +121,10 @@ pass to the OPERATION."
(or (boundp 'ange-ftp-name-format)
(let (file-name-handler-alist) (require 'ange-ftp)))
(let ((ange-ftp-name-format
(list (nth 0 (tramp-file-name-structure))
(nth 3 (tramp-file-name-structure))
(nth 2 (tramp-file-name-structure))
(nth 4 (tramp-file-name-structure))))
(list (nth 0 tramp-file-name-structure)
(nth 3 tramp-file-name-structure)
(nth 2 tramp-file-name-structure)
(nth 4 tramp-file-name-structure)))
;; ange-ftp uses `ange-ftp-ftp-name-arg' and `ange-ftp-ftp-name-res'
;; for optimization in `ange-ftp-ftp-name'. If Tramp wasn't active,
;; there could be incorrect values from previous calls in case the
......
......@@ -3437,7 +3437,7 @@ the result will be a local, non-Tramp, file name."
(let (tramp-vc-registered-file-names
(remote-file-name-inhibit-cache (current-time))
(file-name-handler-alist
`((,(tramp-file-name-regexp) . tramp-vc-file-name-handler))))
`((,tramp-file-name-regexp . tramp-vc-file-name-handler))))
;; Here we collect only file names, which need an operation.
(tramp-with-demoted-errors
......@@ -4468,7 +4468,7 @@ Goes through the list `tramp-inline-compress-commands'."
(let ((user (tramp-file-name-user item))
(host (tramp-file-name-host item))
(proxy (concat
(tramp-prefix-format) proxy (tramp-postfix-host-format))))
tramp-prefix-format proxy tramp-postfix-host-format)))
(tramp-message
vec 5 "Add proxy (\"%s\" \"%s\" \"%s\")"
(and (stringp host) (regexp-quote host))
......
This diff is collapsed.
......@@ -2852,16 +2852,16 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
(tramp-change-syntax syntax)
(let ;; This is needed for the `simplified' syntax.
((method-marker
(if (zerop (length (tramp-method-regexp)))
(if (zerop (length tramp-method-regexp))
"" tramp-default-method-marker))
;; This is needed for the `separate' syntax.
(prefix-format (substring (tramp-prefix-format) 1)))
(prefix-format (substring tramp-prefix-format 1)))
;; Complete method name.
(unless (or (zerop (length method))
(zerop (length (tramp-method-regexp))))
(zerop (length tramp-method-regexp)))
(should
(member
(concat prefix-format method (tramp-postfix-method-format))
(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. With gvfs
......@@ -2873,25 +2873,25 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
(should
(member
(concat
prefix-format method-marker (tramp-postfix-method-format)
host (tramp-postfix-host-format))
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)
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 tramp-method-regexp))
(zerop (length host))
(tramp--test-gvfs-p method))
(should
(member
(concat
prefix-format method (tramp-postfix-method-format)
host (tramp-postfix-host-format))
prefix-format method tramp-postfix-method-format
host tramp-postfix-host-format)
(file-name-all-completions
(concat prefix-format method (tramp-postfix-method-format))
(concat prefix-format method tramp-postfix-method-format)
"/"))))))
;; Cleanup.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment