]> git.eshelyaron.com Git - emacs.git/commitdiff
Implement abbreviate-file-name in Tramp for Google drive
authorMichael Albinus <michael.albinus@gmx.de>
Tue, 8 Mar 2022 16:28:30 +0000 (17:28 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Tue, 8 Mar 2022 16:28:30 +0000 (17:28 +0100)
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-get-home-directory):
Implement for Google drive.

lisp/net/tramp-gvfs.el

index acded25292a817cde189dacef9a59f014da2b1f8..d6120d2bee1046672a2c36ed93dd2c01eac402bc 100644 (file)
@@ -1604,10 +1604,20 @@ If USER is a string, return its home directory instead of the
 user identified by VEC.  If there is no user specified in either
 VEC or USER, or if there is no home directory, return nil."
   (let ((localname
-        (tramp-get-connection-property vec "default-location" nil)))
-    (if (zerop (length localname))
-       (tramp-get-connection-property (tramp-get-process vec) "share" nil)
-      localname)))
+        (tramp-get-connection-property vec "default-location" nil))
+       result)
+    (cond
+     ((zerop (length localname))
+      (tramp-get-connection-property (tramp-get-process vec) "share" nil))
+     ;; Google-drive.
+     ((not (string-prefix-p "/" localname))
+      (dolist (item
+              (tramp-gvfs-get-directory-attributes
+               (tramp-make-tramp-file-name vec "/"))
+              result)
+       (when (string-equal (cdr (assoc "name" item)) localname)
+         (setq result (concat "/" (car item))))))
+     (t localname))))
 
 (defun tramp-gvfs-handle-get-remote-uid (vec id-format)
   "The uid of the remote connection VEC, in ID-FORMAT.