emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 8083c2d: Make `tramp-make-tramp-file-name' calls co


From: Michael Albinus
Subject: [Emacs-diffs] master 8083c2d: Make `tramp-make-tramp-file-name' calls consistent.
Date: Sat, 26 May 2018 08:29:14 -0400 (EDT)

branch: master
commit 8083c2de699cad2fc3cea51480011605fab56484
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    Make `tramp-make-tramp-file-name' calls consistent.
    
    * lisp/net/tramp.el (tramp-get-buffer)
    (tramp-handle-file-name-as-directory)
    (tramp-handle-file-name-directory, tramp-handle-file-remote-p)
    (tramp-handle-file-truename, tramp-handle-find-backup-file-name)
    (tramp-handle-insert-file-contents):
    * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-expand-file-name)
    (tramp-gvfs-get-remote-uid, tramp-gvfs-get-remote-gid)
    (tramp-gvfs-maybe-open-connection):
    * lisp/net/tramp-sh.el (tramp-sh-handle-file-truename)
    (tramp-sh-handle-expand-file-name, )
    (tramp-sh-handle-process-file, tramp-get-remote-path):
    * lisp/net/tramp-smb.el (tramp-smb-handle-expand-file-name)
    (tramp-smb-handle-process-file): Make `tramp-make-tramp-file-name'
    calls consistent.
---
 lisp/net/tramp-gvfs.el | 39 ++++++++++++---------------------------
 lisp/net/tramp-sh.el   | 26 ++++++++++++--------------
 lisp/net/tramp-smb.el  |  6 ++----
 lisp/net/tramp.el      | 42 ++++++++++++++++++++++--------------------
 4 files changed, 48 insertions(+), 65 deletions(-)

diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index ac25081..f547f84 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -1054,8 +1054,7 @@ file names."
       ;; No tilde characters in file name, do normal
       ;; `expand-file-name' (this does "/./" and "/../").
       (tramp-make-tramp-file-name
-       method user domain host port
-       (tramp-run-real-handler 'expand-file-name (list localname))))))
+       v (tramp-run-real-handler 'expand-file-name (list localname))))))
 
 (defun tramp-gvfs-get-directory-attributes (directory)
   "Return GVFS attributes association list of all files in DIRECTORY."
@@ -1885,20 +1884,15 @@ It was \"a(say)\", but has changed to \"a{sv})\"."
   "The uid of the remote connection VEC, in ID-FORMAT.
 ID-FORMAT valid values are `string' and `integer'."
   (with-tramp-connection-property vec (format "uid-%s" id-format)
-    (let ((method (tramp-file-name-method vec))
-         (user (tramp-file-name-user vec))
-         (domain (tramp-file-name-domain vec))
-         (host (tramp-file-name-host vec))
-         (port (tramp-file-name-port vec))
+    (let ((user (tramp-file-name-user vec))
          (localname
           (tramp-get-connection-property vec "default-location" nil)))
       (cond
-       ((and user (equal id-format 'string)) user)
+       ((and (equal id-format 'string) user))
        (localname
        (tramp-compat-file-attribute-user-id
         (file-attributes
-         (tramp-make-tramp-file-name method user domain host port localname)
-         id-format)))
+         (tramp-make-tramp-file-name vec localname) id-format)))
        ((equal id-format 'integer) tramp-unknown-id-integer)
        ((equal id-format 'string) tramp-unknown-id-string)))))
 
@@ -1906,19 +1900,13 @@ ID-FORMAT valid values are `string' and `integer'."
   "The gid of the remote connection VEC, in ID-FORMAT.
 ID-FORMAT valid values are `string' and `integer'."
   (with-tramp-connection-property vec (format "gid-%s" id-format)
-    (let ((method (tramp-file-name-method vec))
-         (user (tramp-file-name-user vec))
-         (domain (tramp-file-name-domain vec))
-         (host (tramp-file-name-host vec))
-         (port (tramp-file-name-port vec))
-         (localname
+    (let ((localname
           (tramp-get-connection-property vec "default-location" nil)))
       (cond
        (localname
        (tramp-compat-file-attribute-group-id
         (file-attributes
-         (tramp-make-tramp-file-name method user domain host port localname)
-         id-format)))
+         (tramp-make-tramp-file-name vec localname) id-format)))
        ((equal id-format 'integer) tramp-unknown-id-integer)
        ((equal id-format 'string) tramp-unknown-id-string)))))
 
@@ -1960,15 +1948,12 @@ connection if a previous connection has died for some 
reason."
       (set-process-query-on-exit-flag p nil)))
 
   (unless (tramp-gvfs-connection-mounted-p vec)
-    (let* ((method (tramp-file-name-method vec))
-          (user (tramp-file-name-user vec))
-          (domain (tramp-file-name-domain vec))
-          (host (tramp-file-name-host vec))
-          (port (tramp-file-name-port vec))
-          (localname (tramp-file-name-unquote-localname vec))
-          (object-path
-           (tramp-gvfs-object-path
-            (tramp-make-tramp-file-name method user domain host port ""))))
+    (let ((method (tramp-file-name-method vec))
+         (user (tramp-file-name-user vec))
+         (host (tramp-file-name-host vec))
+         (localname (tramp-file-name-unquote-localname vec))
+         (object-path
+          (tramp-gvfs-object-path (tramp-make-tramp-file-name vec 'noloc))))
 
       (when (and (string-equal method "afp")
                 (string-equal localname "/"))
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 227fd9c..76dae9c 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -1125,7 +1125,7 @@ component is used as the target of the symlink."
        'file-name-as-directory 'identity)
    (with-parsed-tramp-file-name (expand-file-name filename) nil
      (tramp-make-tramp-file-name
-      method user domain host port
+      v
       (with-tramp-file-property v localname "file-truename"
        (let ((result nil)                      ; result steps in reverse order
              (quoted (tramp-compat-file-name-quoted-p localname))
@@ -1177,12 +1177,13 @@ component is used as the target of the symlink."
                        (tramp-compat-file-attribute-type
                         (file-attributes
                          (tramp-make-tramp-file-name
-                          method user domain host port
+                          v
                           (mapconcat 'identity
                                      (append '("")
                                              (reverse result)
                                              (list thisstep))
-                                    "/")))))
+                                     "/")
+                          'nohop))))
                  (cond ((string= "." thisstep)
                         (tramp-message v 5 "Ignoring step `.'"))
                        ((string= ".." thisstep)
@@ -1226,7 +1227,8 @@ component is used as the target of the symlink."
            (let (file-name-handler-alist)
              (setq result (tramp-compat-file-name-quote result))))
          (tramp-message v 4 "True name of `%s' is `%s'" localname result)
-         result))))))
+         result))
+      'nohop))))
 
 ;; Basic functions.
 
@@ -2804,11 +2806,9 @@ the result will be a local, non-Tramp, file name."
       ;; be problems with UNC shares or Cygwin mounts.
       (let ((default-directory (tramp-compat-temporary-file-directory)))
        (tramp-make-tramp-file-name
-        method user domain host port
-        (tramp-drop-volume-letter
-         (tramp-run-real-handler
-          'expand-file-name (list localname)))
-        hop)))))
+        v (tramp-drop-volume-letter
+           (tramp-run-real-handler
+            'expand-file-name (list localname))))))))
 
 ;;; Remote commands:
 
@@ -2997,8 +2997,7 @@ the result will be a local, non-Tramp, file name."
            (setq input (with-parsed-tramp-file-name infile nil localname))
          ;; INFILE must be copied to remote host.
          (setq input (tramp-make-tramp-temp-file v)
-               tmpinput
-               (tramp-make-tramp-file-name method user domain host port input))
+               tmpinput (tramp-make-tramp-file-name v input 'nohop))
          (copy-file infile tmpinput t)))
       (when input (setq command (format "%s <%s" command input)))
 
@@ -3031,8 +3030,7 @@ the result will be a local, non-Tramp, file name."
            ;; stderr must be copied to remote host.  The temporary
            ;; file must be deleted after execution.
            (setq stderr (tramp-make-tramp-temp-file v)
-                 tmpstderr (tramp-make-tramp-file-name
-                            method user domain host port stderr))))
+                 tmpstderr (tramp-make-tramp-file-name v stderr 'nohop))))
         ;; stderr to be discarded.
         ((null (cadr destination))
          (setq stderr "/dev/null"))))
@@ -5294,7 +5292,7 @@ Nonexistent directories are removed from spec."
        (lambda (x)
          (and
           (stringp x)
-          (file-directory-p (tramp-make-tramp-file-name vec x))
+          (file-directory-p (tramp-make-tramp-file-name vec x 'nohop))
           x))
        remote-path)))))
 
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index c2df2e2..0334f05 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -715,8 +715,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
       ;; No tilde characters in file name, do normal
       ;; `expand-file-name' (this does "/./" and "/../").
       (tramp-make-tramp-file-name
-       method user domain host port
-       (tramp-run-real-handler 'expand-file-name (list localname))))))
+       v (tramp-run-real-handler 'expand-file-name (list localname))))))
 
 (defun tramp-smb-action-get-acl (proc vec)
   "Read ACL data from connection buffer."
@@ -1235,8 +1234,7 @@ component is used as the target of the symlink."
            (setq input (with-parsed-tramp-file-name infile nil localname))
          ;; INFILE must be copied to remote host.
          (setq input (tramp-make-tramp-temp-file v)
-               tmpinput
-               (tramp-make-tramp-file-name method user domain host port input))
+               tmpinput (tramp-make-tramp-file-name v input))
          (copy-file infile tmpinput t))
        ;; Transform input into a filename powershell does understand.
        (setq input (format "//%s%s" host input)))
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 3983728..1d6e014 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -1462,7 +1462,7 @@ necessary only.  This function will be used in file name 
completion."
         vec "process-buffer"
         (tramp-get-connection-property vec "process-buffer" nil))
        (setq buffer-undo-list t
-             default-directory (tramp-make-tramp-file-name vec "/" 'nohop))
+             default-directory (tramp-make-tramp-file-name vec 'noloc 'nohop))
        (current-buffer))))
 
 (defun tramp-get-connection-buffer (vec)
@@ -3072,11 +3072,11 @@ User is always nil."
     ;; Run the command on the localname portion only unless we are in
     ;; completion mode.
     (tramp-make-tramp-file-name
-     v (unless (and (zerop (length (tramp-file-name-localname v)))
-                   (not (tramp-connectable-p file)))
-        (tramp-run-real-handler
-         'file-name-as-directory
-         (list (or (tramp-file-name-localname v) "")))))))
+     v (or (and (zerop (length (tramp-file-name-localname v)))
+               (not (tramp-connectable-p file)))
+          (tramp-run-real-handler
+           'file-name-as-directory
+           (list (tramp-file-name-localname v)))))))
 
 (defun tramp-handle-file-name-case-insensitive-p (filename)
   "Like `file-name-case-insensitive-p' for Tramp files."
@@ -3153,11 +3153,16 @@ User is always nil."
 
 (defun tramp-handle-file-name-directory (file)
   "Like `file-name-directory' but aware of Tramp files."
-  (with-parsed-tramp-file-name file nil
-    (setf (tramp-file-name-localname v) nil)
-    ;; Run the command on the localname portion only.
+  ;; Everything except the last filename thing is the directory.  We
+  ;; cannot apply `with-parsed-tramp-file-name', because this expands
+  ;; the remote file name parts.
+  (let ((v (tramp-dissect-file-name file t)))
+    ;; Run the command on the localname portion only.  If this returns
+    ;; nil, mark also the localname part of `v' as nil.
     (tramp-make-tramp-file-name
-     v (tramp-run-real-handler'file-name-directory (list localname)))))
+     v (or (tramp-run-real-handler
+           'file-name-directory (list (tramp-file-name-localname v)))
+          'noloc))))
 
 (defun tramp-handle-file-name-nondirectory (file)
   "Like `file-name-nondirectory' but aware of Tramp files."
@@ -3202,8 +3207,7 @@ User is always nil."
                ((eq identification 'host) (tramp-file-name-host-port v))
                ((eq identification 'localname) localname)
                ((eq identification 'hop) hop)
-               (t (tramp-make-tramp-file-name
-                   method user domain host port "" hop)))))))))
+               (t (tramp-make-tramp-file-name v 'noloc)))))))))
 
 (defun tramp-handle-file-selinux-context (_filename)
   "Like `file-selinux-context' for Tramp files."
@@ -3237,7 +3241,7 @@ User is always nil."
                 result
                 (with-parsed-tramp-file-name (expand-file-name result) v2
                   (tramp-make-tramp-file-name
-                   v2-method v2-user v2-domain v2-host v2-port
+                   v2
                    (funcall
                     (if (tramp-compat-file-name-quoted-p v2-localname)
                         'tramp-compat-file-name-quote 'identity)
@@ -3248,7 +3252,8 @@ User is always nil."
                               (tramp-compat-file-name-quote symlink-target))
                           (expand-file-name
                            symlink-target (file-name-directory v2-localname)))
-                      v2-localname)))))
+                      v2-localname))
+                   'nohop)))
           (when (>= numchase numchase-limit)
             (tramp-error
              v1 'file-error
@@ -3267,8 +3272,7 @@ User is always nil."
                   (if (and (stringp (cdr x))
                            (file-name-absolute-p (cdr x))
                            (not (tramp-tramp-file-p (cdr x))))
-                      (tramp-make-tramp-file-name
-                       method user domain host port (cdr x) hop)
+                      (tramp-make-tramp-file-name v (cdr x))
                     (cdr x))))
                tramp-backup-directory-alist)
             backup-directory-alist)))
@@ -3373,7 +3377,7 @@ User is always nil."
                             ((stringp remote-copy)
                              (file-local-copy
                               (tramp-make-tramp-file-name
-                               method user domain host port remote-copy)))
+                               v remote-copy 'nohop)))
                             ((stringp tramp-temp-buffer-file-name)
                              (copy-file
                               filename tramp-temp-buffer-file-name 'ok)
@@ -3417,9 +3421,7 @@ User is always nil."
                     (or remote-copy (null tramp-temp-buffer-file-name)))
            (delete-file local-copy))
          (when (stringp remote-copy)
-           (delete-file
-            (tramp-make-tramp-file-name
-             method user domain host port remote-copy)))))
+           (delete-file (tramp-make-tramp-file-name v remote-copy 'nohop)))))
 
       ;; Result.
       (list (expand-file-name filename)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]