From: Michael Albinus Date: Tue, 30 Jan 2018 19:09:20 +0000 (+0100) Subject: Simplify last change in tramp-archive X-Git-Tag: emacs-27.0.90~5769 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=386c2ebb58c403c647a1dae1314be4b9f2071f56;p=emacs.git Simplify last change in tramp-archive --- diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el index ac8b76b9442..51ee18fac7a 100644 --- a/lisp/net/tramp-archive.el +++ b/lisp/net/tramp-archive.el @@ -315,26 +315,23 @@ name is kept in slot `hop'" (unless (tramp-archive-file-name-p name) (tramp-compat-user-error nil "Not an archive file name: \"%s\"" name)) ;; The `string-match' happened in `tramp-archive-file-name-p'. - (let ((archive (match-string 1 name)) - (localname (match-string 2 name)) - (tramp-verbose 0) - vec copy) - - (setq archive (file-truename archive)) + (let* ((localname (match-string 2 name)) + (archive (file-truename (match-string 1 name))) + (vec (make-tramp-file-name + :method tramp-archive-method :hop archive))) (cond ;; The value is already in the hash table. - ((setq vec (car (gethash archive tramp-archive-hash)))) + ((gethash archive tramp-archive-hash) + (setq vec (car (gethash archive tramp-archive-hash)))) ;; File archives inside file archives. ((tramp-archive-file-name-p archive) (let ((archive (tramp-make-tramp-file-name (tramp-archive-dissect-file-name archive) nil 'noarchive))) - (setq vec - (make-tramp-file-name - :method tramp-archive-method :hop archive - :host (url-hexify-string (tramp-gvfs-url-file-name archive))))) + (setf (tramp-file-name-host vec) + (url-hexify-string (tramp-gvfs-url-file-name archive)))) (puthash archive (list vec) tramp-archive-hash)) ;; http://... @@ -347,34 +344,29 @@ name is kept in slot `hop'" (url-type (url-generic-parse-url archive)) url-tramp-protocols)) (archive (url-tramp-convert-url-to-tramp archive))) - (setq vec - (make-tramp-file-name - :method tramp-archive-method :hop archive - :host (url-hexify-string (tramp-gvfs-url-file-name archive))))) - (puthash archive (list vec) tramp-archive-hash)) + (setf (tramp-file-name-host vec) + (url-hexify-string (tramp-gvfs-url-file-name archive)))) + (puthash archive (list vec) tramp-archive-hash)) ;; GVFS supported schemes. ((or (tramp-gvfs-file-name-p archive) (not (file-remote-p archive))) - (setq vec - (make-tramp-file-name - :method tramp-archive-method :hop archive - :host (url-hexify-string (tramp-gvfs-url-file-name archive)))) + (setf (tramp-file-name-host vec) + (url-hexify-string (tramp-gvfs-url-file-name archive))) (puthash archive (list vec) tramp-archive-hash)) ;; Anything else. Here we call `file-local-copy', which we ;; have avoided so far. - (t (let ((inhibit-file-name-operation 'file-local-copy) - (inhibit-file-name-handlers - (cons 'jka-compr-handler inhibit-file-name-handlers))) - (setq copy (file-local-copy archive) - vec - (make-tramp-file-name - :method tramp-archive-method :hop archive - :host (url-hexify-string (tramp-gvfs-url-file-name copy))))) - (puthash archive (cons vec copy) tramp-archive-hash))) - - ;; So far, `vec' handles just the mount point. Add `localname'. + (t (let* ((inhibit-file-name-operation 'file-local-copy) + (inhibit-file-name-handlers + (cons 'jka-compr-handler inhibit-file-name-handlers)) + (copy (file-local-copy archive))) + (setf (tramp-file-name-host vec) + (url-hexify-string (tramp-gvfs-url-file-name copy))) + (puthash archive (cons vec copy) tramp-archive-hash)))) + + ;; So far, `vec' handles just the mount point. Add `localname', + ;; which shouldn't be pushed to the hash. (setf (tramp-file-name-localname vec) localname) vec))) diff --git a/test/lisp/net/tramp-archive-tests.el b/test/lisp/net/tramp-archive-tests.el index 82dd5de8b9a..ecfee0c556c 100644 --- a/test/lisp/net/tramp-archive-tests.el +++ b/test/lisp/net/tramp-archive-tests.el @@ -186,11 +186,7 @@ variables, so we check the Emacs version directly." (file-name-nondirectory tramp-archive-test-file-archive))))) (should-not port) (should (string-equal localname "/bar")) - ;; The `archive' component is now already a Tramp file name. - (should - (string-equal - archive - (tramp-archive-gvfs-file-name tramp-archive-test-file-archive)))) + (should (string-equal archive tramp-archive-test-file-archive))) ;; Cleanup. (tramp-archive-cleanup-hash))))