summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2018-11-22 16:29:25 +0100
committerMichael Albinus <michael.albinus@gmx.de>2018-11-22 16:29:25 +0100
commita344d9937bb7edfbfbea13dca1569fcdcad25ac2 (patch)
treeeb794729c0c86c65b30ce3456864f216f5648ed5
parentad063d2552d4d31fa668fa5f15a91aec18c010f6 (diff)
downloademacs-a344d9937bb7edfbfbea13dca1569fcdcad25ac2.tar.gz
Some minor Tramp cleanups
* lisp/net/tramp-adb.el (tramp-adb-file-name-p): * lisp/net/tramp-ftp.el (tramp-ftp-file-name-p): * lisp/net/tramp-smb.el (tramp-smb-file-name-p): Make it more robust. * lisp/net/tramp.el (tramp-handle-file-truename): Cache only the localname.
-rw-r--r--lisp/net/tramp-adb.el5
-rw-r--r--lisp/net/tramp-ftp.el5
-rw-r--r--lisp/net/tramp-gvfs.el2
-rw-r--r--lisp/net/tramp-smb.el5
-rw-r--r--lisp/net/tramp.el53
5 files changed, 38 insertions, 32 deletions
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 36374f88e0d..00c6ad43ea1 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -173,8 +173,9 @@ It is used for TCP/IP devices."
;;;###tramp-autoload
(defsubst tramp-adb-file-name-p (filename)
"Check if it's a filename for ADB."
- (let ((v (tramp-dissect-file-name filename)))
- (string= (tramp-file-name-method v) tramp-adb-method)))
+ (and (tramp-tramp-file-p filename)
+ (string= (tramp-file-name-method (tramp-dissect-file-name filename))
+ tramp-adb-method)))
;;;###tramp-autoload
(defun tramp-adb-file-name-handler (operation &rest args)
diff --git a/lisp/net/tramp-ftp.el b/lisp/net/tramp-ftp.el
index 983f168ddb4..5d8b56e218f 100644
--- a/lisp/net/tramp-ftp.el
+++ b/lisp/net/tramp-ftp.el
@@ -183,8 +183,9 @@ pass to the OPERATION."
;;;###tramp-autoload
(defsubst tramp-ftp-file-name-p (filename)
"Check if it's a filename that should be forwarded to Ange-FTP."
- (string= (tramp-file-name-method (tramp-dissect-file-name filename))
- tramp-ftp-method))
+ (and (tramp-tramp-file-p filename)
+ (string= (tramp-file-name-method (tramp-dissect-file-name filename))
+ tramp-ftp-method)))
;;;###tramp-autoload
(add-to-list 'tramp-foreign-file-name-handler-alist
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index c150edf3f13..fb687f0d7bd 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -2088,7 +2088,7 @@ This uses \"avahi-browse\" in case D-Bus is not enabled in Avahi."
;;; TODO:
;; * (Customizable) unmount when exiting Emacs. See tramp-archive.el.
-
+;;
;; * Host name completion for existing mount points (afp-server,
;; smb-server, google-drive, nextcloud) or via smb-network or network.
;;
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index a97b8017300..eadb4029b54 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -321,8 +321,9 @@ This can be used to disable echo etc."
;;;###tramp-autoload
(defsubst tramp-smb-file-name-p (filename)
"Check if it's a filename for SMB servers."
- (string= (tramp-file-name-method (tramp-dissect-file-name filename))
- tramp-smb-method))
+ (and (tramp-tramp-file-p filename)
+ (string= (tramp-file-name-method (tramp-dissect-file-name filename))
+ tramp-smb-method)))
;;;###tramp-autoload
(defun tramp-smb-file-name-handler (operation &rest args)
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 8362d787525..97f931a4a44 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3301,31 +3301,34 @@ User is always nil."
(numchase-limit 20)
symlink-target)
(with-parsed-tramp-file-name result v1
- (with-tramp-file-property v1 v1-localname "file-truename"
- (while (and (setq symlink-target (file-symlink-p result))
- (< numchase numchase-limit))
- (setq numchase (1+ numchase)
- result
- (with-parsed-tramp-file-name (expand-file-name result) v2
- (tramp-make-tramp-file-name
- v2
- (funcall
- (if (tramp-compat-file-name-quoted-p v2-localname)
- 'tramp-compat-file-name-quote 'identity)
-
- (if (stringp symlink-target)
- (if (file-remote-p symlink-target)
- (let (file-name-handler-alist)
- (tramp-compat-file-name-quote symlink-target))
- (expand-file-name
- symlink-target (file-name-directory v2-localname)))
- v2-localname))
- 'nohop)))
- (when (>= numchase numchase-limit)
- (tramp-error
- v1 'file-error
- "Maximum number (%d) of symlinks exceeded" numchase-limit)))
- (directory-file-name result))))))
+ ;; We cache only the localname.
+ (tramp-make-tramp-file-name
+ v1
+ (with-tramp-file-property v1 v1-localname "file-truename"
+ (while (and (setq symlink-target (file-symlink-p result))
+ (< numchase numchase-limit))
+ (setq numchase (1+ numchase)
+ result
+ (with-parsed-tramp-file-name (expand-file-name result) v2
+ (tramp-make-tramp-file-name
+ v2
+ (funcall
+ (if (tramp-compat-file-name-quoted-p v2-localname)
+ 'tramp-compat-file-name-quote 'identity)
+
+ (if (stringp symlink-target)
+ (if (file-remote-p symlink-target)
+ (let (file-name-handler-alist)
+ (tramp-compat-file-name-quote symlink-target))
+ (expand-file-name
+ symlink-target (file-name-directory v2-localname)))
+ v2-localname))
+ 'nohop)))
+ (when (>= numchase numchase-limit)
+ (tramp-error
+ v1 'file-error
+ "Maximum number (%d) of symlinks exceeded" numchase-limit)))
+ (file-local-name (directory-file-name result))))))))
(defun tramp-handle-find-backup-file-name (filename)
"Like `find-backup-file-name' for Tramp files."