]> code.delx.au - gnu-emacs/commitdiff
* net/tramp.el (tramp-handle-make-symbolic-link)
authorMichael Albinus <michael.albinus@gmx.de>
Sun, 27 Apr 2008 16:39:03 +0000 (16:39 +0000)
committerMichael Albinus <michael.albinus@gmx.de>
Sun, 27 Apr 2008 16:39:03 +0000 (16:39 +0000)
(tramp-handle-file-name-directory)
(tramp-handle-file-name-nondirectory, tramp-handle-file-truename)
(tramp-do-copy-or-rename-file-directly)
(tramp-handle-insert-directory, tramp-handle-expand-file-name)
(tramp-handle-substitute-in-file-name)
(tramp-handle-insert-file-contents, tramp-handle-write-region)
* net/tramp-cache.el (tramp-get-file-property)
(tramp-set-file-property, tramp-flush-file-property)
(tramp-flush-directory-property)
* net/tramp-cpmpat.el (tramp-compat-make-temp-file)
* net/tramp-fish.el (tramp-fish-handle-expand-file-name): Disable
`file-name-handler-alist' when handling localname.  It could have
a remote file syntax, like a VMS file name.

lisp/ChangeLog
lisp/net/tramp-cache.el
lisp/net/tramp-compat.el
lisp/net/tramp-fish.el
lisp/net/tramp.el

index c7150bab8ec0a6acb3f0b21662668a255a94486a..10a3060edfea4653e70a31844219b227d0a7a49c 100644 (file)
@@ -1,3 +1,20 @@
+2008-04-27  Michael Albinus  <michael.albinus@gmx.de>
+
+       * net/tramp.el (tramp-handle-make-symbolic-link)
+       (tramp-handle-file-name-directory)
+       (tramp-handle-file-name-nondirectory, tramp-handle-file-truename)
+       (tramp-do-copy-or-rename-file-directly)
+       (tramp-handle-insert-directory, tramp-handle-expand-file-name)
+       (tramp-handle-substitute-in-file-name)
+       (tramp-handle-insert-file-contents, tramp-handle-write-region)
+       * net/tramp-cache.el (tramp-get-file-property)
+       (tramp-set-file-property, tramp-flush-file-property)
+       (tramp-flush-directory-property)
+       * net/tramp-compat.el (tramp-compat-make-temp-file)
+       * net/tramp-fish.el (tramp-fish-handle-expand-file-name): Disable
+       `file-name-handler-alist' when handling localname.  It could have
+       a remote file syntax, like a VMS file name.
+
 2008-04-27  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
 
        * whitespace.el: New version 11.1.
index 945823959cd349e4b561524e9c5407b71deeef48..32c2a4a18f69f747c2acaeebb652068999e4ab59 100644 (file)
@@ -95,7 +95,7 @@
 Returns DEFAULT if not set."
   ;; Unify localname.
   (setq vec (copy-sequence vec))
-  (aset vec 3 (directory-file-name file))
+  (aset vec 3 (tramp-run-real-handler 'directory-file-name (list file)))
   (let* ((hash (or (gethash vec tramp-cache-data)
                   (puthash vec (make-hash-table :test 'equal)
                            tramp-cache-data)))
@@ -110,7 +110,7 @@ Returns DEFAULT if not set."
 Returns VALUE."
   ;; Unify localname.
   (setq vec (copy-sequence vec))
-  (aset vec 3 (directory-file-name file))
+  (aset vec 3 (tramp-run-real-handler 'directory-file-name (list file)))
   (let ((hash (or (gethash vec tramp-cache-data)
                  (puthash vec (make-hash-table :test 'equal)
                           tramp-cache-data))))
@@ -122,14 +122,15 @@ Returns VALUE."
   "Remove all properties of FILE in the cache context of VEC."
   ;; Unify localname.
   (setq vec (copy-sequence vec))
-  (aset vec 3 (directory-file-name file))
+  (aset vec 3 (tramp-run-real-handler 'directory-file-name (list file)))
   (tramp-message vec 8 "%s" file)
   (remhash vec tramp-cache-data))
 
 (defun tramp-flush-directory-property (vec directory)
   "Remove all properties of DIRECTORY in the cache context of VEC.
 Remove also properties of all files in subdirectories."
-  (let ((directory (directory-file-name directory)))
+  (let ((directory (tramp-run-real-handler
+                   'directory-file-name (list directory))))
   (tramp-message vec 8 "%s" directory)
     (maphash
      '(lambda (key value)
index b07ffd5f56d392c2a991b3d1cf971b070ba4bf53..0f66ee2183d0795a80960fc0f0d8f99bf077096b 100644 (file)
@@ -153,11 +153,12 @@ this is the function `temp-directory'."
 (defsubst tramp-compat-make-temp-file (filename)
   "Create a temporary file (compat function).
 Add the extension of FILENAME, if existing."
-  (let ((prefix (expand-file-name
-                (symbol-value 'tramp-temp-name-prefix)
-                (tramp-compat-temporary-file-directory)))
-       (extension (file-name-extension filename t))
-       result)
+  (let* (file-name-handler-alist
+        (prefix (expand-file-name
+                 (symbol-value 'tramp-temp-name-prefix)
+                 (tramp-compat-temporary-file-directory)))
+        (extension (file-name-extension filename t))
+        result)
     (condition-case nil
        (setq result
              (funcall (symbol-function 'make-temp-file) prefix nil extension))
index 639ea60f2a0b9e732e854c7cafa2acd3728e0329..ee13d1e45163277f54ebdeadd40954b5cd83f299 100644 (file)
@@ -352,7 +352,7 @@ pass to the OPERATION."
        (tramp-run-real-handler 'expand-file-name (list name nil)))
     ;; Dissect NAME.
     (with-parsed-tramp-file-name name nil
-      (unless (file-name-absolute-p localname)
+      (unless (tramp-run-real-handler 'file-name-absolute-p (list localname))
        (setq localname (concat "~/" localname)))
       ;; Tilde expansion if necessary.
       (when (string-match "\\`\\(~[^/]*\\)\\(.*\\)\\'" localname)
@@ -385,8 +385,8 @@ pass to the OPERATION."
        (tramp-make-tramp-file-name
         method user host
         (tramp-drop-volume-letter
-         (tramp-run-real-handler 'expand-file-name
-                                 (list localname))))))))
+         (tramp-run-real-handler
+          'expand-file-name (list localname))))))))
 
 (defun tramp-fish-handle-file-attributes (filename &optional id-format)
   "Like `file-attributes' for Tramp files."
index 4b0b66abf7f52f035be53a1647af4b1bad25ce61..1008897d9ea8de9e62c142902586bcdf2b892edd 100644 (file)
@@ -2119,7 +2119,8 @@ this can give surprising results if the user/host for the source and
 target of the symlink differ."
   (with-parsed-tramp-file-name linkname l
     (let ((ln (tramp-get-remote-ln l))
-         (cwd (file-name-directory l-localname)))
+         (cwd (tramp-run-real-handler
+               'file-name-directory (list l-localname))))
       (unless ln
        (tramp-error
         l 'file-error
@@ -2151,7 +2152,6 @@ target of the symlink differ."
        (tramp-send-command-and-check
        l (format "cd %s && %s -sf %s %s" cwd ln filename l-localname) t)))))
 
-
 (defun tramp-handle-load (file &optional noerror nomessage nosuffix must-suffix)
   "Like `load' for Tramp files."
   (with-parsed-tramp-file-name (expand-file-name file) nil
@@ -2194,12 +2194,13 @@ target of the symlink differ."
      (tramp-file-name-method v)
      (tramp-file-name-user v)
      (tramp-file-name-host v)
-     (file-name-directory (or (tramp-file-name-localname v) "")))))
+     (tramp-run-real-handler
+      'file-name-directory (list (or (tramp-file-name-localname v) ""))))))
 
 (defun tramp-handle-file-name-nondirectory (file)
   "Like `file-name-nondirectory' but aware of Tramp files."
   (with-parsed-tramp-file-name file nil
-    (file-name-nondirectory localname)))
+    (tramp-run-real-handler 'file-name-nondirectory (list localname))))
 
 (defun tramp-handle-file-truename (filename &optional counter prev-dirs)
   "Like `file-truename' for Tramp files."
@@ -2207,7 +2208,8 @@ target of the symlink differ."
     (with-file-property v localname "file-truename"
       (let* ((directory-sep-char ?/) ; for XEmacs
             (steps (tramp-split-string localname "/"))
-            (localnamedir (file-name-as-directory localname))
+            (localnamedir (tramp-run-real-handler
+                           'file-name-as-directory (list localname)))
             (is-dir (string= localname localnamedir))
             (thisstep nil)
             (numchase 0)
@@ -3128,20 +3130,23 @@ the uid and gid from FILENAME."
         ((or t1 t2)
          (cond
           ;; We can do it directly.
-          ((and (file-readable-p localname1)
-                (file-writable-p (file-name-directory localname2))
-                (or (file-directory-p localname2)
-                    (file-writable-p localname2)))
+          ((let (file-name-handler-alist)
+             (and (file-readable-p localname1)
+                  (file-writable-p (file-name-directory localname2))
+                  (or (file-directory-p localname2)
+                      (file-writable-p localname2))))
            (if (eq op 'copy)
                (tramp-compat-copy-file
                 localname1 localname2 ok-if-already-exists
                 keep-date preserve-uid-gid)
-             (rename-file localname1 localname2 ok-if-already-exists)))
+             (tramp-run-real-handler
+              'rename-file (list localname1 localname2 ok-if-already-exists))))
 
           ;; We can do it directly with `tramp-send-command'
-          ((and (file-readable-p (concat prefix localname1))
+          ((let (file-name-handler-alist)
+             (and (file-readable-p (concat prefix localname1))
                 (file-writable-p
-                 (file-name-directory (concat prefix localname2))))
+                 (file-name-directory (concat prefix localname2)))))
            (tramp-do-copy-or-rename-file-directly
             op (concat prefix localname1) (concat prefix localname2)
             ok-if-already-exists keep-date t)
@@ -3172,7 +3177,8 @@ the uid and gid from FILENAME."
                    (tramp-compat-copy-file
                     localname1 tmpfile ok-if-already-exists
                     keep-date preserve-uid-gid)
-                 (rename-file localname1 tmpfile ok-if-already-exists))
+                 (tramp-run-real-handler
+                  'rename-file (list localname1 tmpfile ok-if-already-exists)))
                ;; We must change the ownership as local user.
                (tramp-set-file-uid-gid
                 tmpfile
@@ -3188,7 +3194,9 @@ the uid and gid from FILENAME."
                    (tramp-shell-quote-argument tmpfile)
                    (tramp-shell-quote-argument localname2))))
               (t1
-               (rename-file tmpfile localname2 ok-if-already-exists)))))))))
+               (tramp-run-real-handler
+                'rename-file
+                (list tmpfile localname2 ok-if-already-exists))))))))))
 
       ;; Set the time and mode. Mask possible errors.
       ;; Won't be applied for 'rename.
@@ -3198,7 +3206,6 @@ the uid and gid from FILENAME."
            (set-file-modes newname (file-modes filename)))
        (error)))))
 
-
 (defun tramp-do-copy-or-rename-file-out-of-band (op filename newname keep-date)
   "Invoke rcp program to copy.
 One of FILENAME and NEWNAME must be a Tramp name, the other must
@@ -3450,8 +3457,10 @@ This is like `dired-recursive-delete-directory' for Tramp files."
        switches filename (if wildcard "yes" "no")
        (if full-directory-p "yes" "no"))
       (when wildcard
-        (setq wildcard (file-name-nondirectory localname))
-        (setq localname (file-name-directory localname)))
+        (setq wildcard (tramp-run-real-handler
+                       'file-name-nondirectory (list localname)))
+        (setq localname (tramp-run-real-handler
+                        'file-name-directory (list localname))))
       (when (listp switches)
         (setq switches (mapconcat 'identity switches " ")))
       (unless full-directory-p
@@ -3472,19 +3481,24 @@ This is like `dired-recursive-delete-directory' for Tramp files."
        (tramp-barf-unless-okay
         v
         (format "cd %s" (tramp-shell-quote-argument
-                         (file-name-directory localname)))
+                         (tramp-run-real-handler
+                          'file-name-directory (list localname))))
         "Couldn't `cd %s'"
-        (tramp-shell-quote-argument (file-name-directory localname)))
+        (tramp-shell-quote-argument
+         (tramp-run-real-handler 'file-name-directory (list localname))))
        (tramp-send-command
         v
         (format "%s %s %s"
                 (tramp-get-ls-command v)
                 switches
                 (if (or wildcard
-                        (zerop (length (file-name-nondirectory localname))))
+                        (zerop (length
+                                (tramp-run-real-handler
+                                 'file-name-nondirectory (list localname)))))
                     ""
                   (tramp-shell-quote-argument
-                   (file-name-nondirectory localname))))))
+                   (tramp-run-real-handler
+                    'file-name-nondirectory (list localname)))))))
       ;; We cannot use `insert-buffer-substring' because the Tramp buffer
       ;; changes its contents before insertion due to calling
       ;; `expand-file' and alike.
@@ -3514,7 +3528,7 @@ the result will be a local, non-Tramp, filename."
       (tramp-run-real-handler 'expand-file-name (list name nil))
     ;; Dissect NAME.
     (with-parsed-tramp-file-name name nil
-      (unless (file-name-absolute-p localname)
+      (unless (tramp-run-real-handler 'file-name-absolute-p (list localname))
        (setq localname (concat "~/" localname)))
       ;; Tilde expansion if necessary.  This needs a shell which
       ;; groks tilde expansion!  The function `tramp-find-shell' is
@@ -3554,8 +3568,8 @@ the result will be a local, non-Tramp, filename."
        (tramp-make-tramp-file-name
         method user host
         (tramp-drop-volume-letter
-         (tramp-run-real-handler 'expand-file-name
-                                 (list localname))))))))
+         (tramp-run-real-handler
+          'expand-file-name (list localname))))))))
 
 (defun tramp-replace-environment-variables (filename)
   "Replace environment variables in FILENAME.
@@ -3586,7 +3600,9 @@ beginning of local filename are not substituted."
           (when method (substitute-in-file-name method))
           (when user (substitute-in-file-name user))
           (when host (substitute-in-file-name host))
-          (when localname (substitute-in-file-name localname))))
+          (when localname
+            (tramp-run-real-handler
+             'substitute-in-file-name (list localname)))))
       ;; Ignore in LOCALNAME everything before "//" or "/~".
       (when (and (stringp localname) (string-match ".+?/\\(/\\|~\\)" localname))
        (setq filename
@@ -3968,9 +3984,12 @@ coding system might not be determined.  This function repairs it."
            (list (expand-file-name filename) 0))
 
        (if (and (tramp-local-host-p v)
-                (file-readable-p localname))
+                (let (file-name-handler-alist) (file-readable-p localname)))
            ;; Short track: if we are on the local host, we can run directly.
-           (setq result (insert-file-contents localname visit beg end replace))
+           (setq result
+                 (tramp-run-real-handler
+                  'insert-file-contents
+                  (list localname visit beg end replace)))
 
          ;; `insert-file-contents-literally' takes care to avoid calling
          ;; jka-compr.  By let-binding inhibit-file-name-operation, we
@@ -4146,11 +4165,16 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
                   (tramp-get-remote-gid v 'integer))))
 
       (if (and (tramp-local-host-p v)
-              (file-writable-p (file-name-directory localname))
-              (or (file-directory-p localname)
-                  (file-writable-p localname)))
+              ;; `file-writable-p' calls 'file-expand-file-name'.  We
+              ;; cannot use `tramp-run-real-handler' therefore.
+              (let (file-name-handler-alist)
+                (file-writable-p (file-name-directory localname))
+                (or (file-directory-p localname)
+                    (file-writable-p localname))))
          ;; Short track: if we are on the local host, we can run directly.
-         (write-region start end localname append 'no-message lockname confirm)
+         (tramp-run-real-handler
+          'write-region
+          (list start end localname append 'no-message lockname confirm))
 
        (let ((rem-dec (tramp-get-remote-coding v "remote-decoding"))
              (loc-enc (tramp-get-local-coding v "local-encoding"))
@@ -6644,7 +6668,6 @@ Not actually used.  Use `(format \"%o\" i)' instead?"
         (t (concat (tramp-decimal-to-octal (/ i 8))
                    (number-to-string (% i 8))))))
 
-
 ;; Kudos to Gerd Moellmann for this suggestion.
 (defun tramp-octal-to-decimal (ostr)
   "Given a string of octal digits, return a decimal number."