[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master a4dd94de80: Don't attempt to connect to a remote server during 'a
From: |
Stefan Monnier |
Subject: |
master a4dd94de80: Don't attempt to connect to a remote server during 'abbreviate-file-name' |
Date: |
Tue, 15 Feb 2022 08:10:27 -0500 (EST) |
branch: master
commit a4dd94de8018e75fc5c000cff5f57b4a53f05042
Author: Jim Porter <jporterbugs@gmail.com>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
Don't attempt to connect to a remote server during 'abbreviate-file-name'
* lisp/net/tramp.el (tramp-handle-abbreviate-file-name): Only use the
"home-directory" when a connection has been established.
---
lisp/net/tramp.el | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 32712efb3e..3c06ad1630 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3343,16 +3343,24 @@ User is always nil."
(let* ((case-fold-search (file-name-case-insensitive-p filename))
(vec (tramp-dissect-file-name filename))
(home-dir
- (with-tramp-connection-property vec "home-directory"
- (tramp-compat-funcall
- 'directory-abbrev-apply
- (expand-file-name (tramp-make-tramp-file-name vec "~"))))))
+ (if (let ((non-essential t)) (tramp-connectable-p vec))
+ ;; If a connection has already been established, make
+ ;; sure the "home-directory" connection property is
+ ;; properly set.
+ (with-tramp-connection-property vec "home-directory"
+ (tramp-compat-funcall
+ 'directory-abbrev-apply
+ (expand-file-name (tramp-make-tramp-file-name vec "~"))))
+ ;; Otherwise, just use the cached value.
+ (tramp-get-connection-property vec "home-directory" nil))))
;; If any elt of `directory-abbrev-alist' matches this name,
;; abbreviate accordingly.
(setq filename (tramp-compat-funcall 'directory-abbrev-apply filename))
;; Abbreviate home directory.
- (if (string-match
- (tramp-compat-funcall 'directory-abbrev-make-regexp home-dir) filename)
+ (if (and home-dir
+ (string-match
+ (tramp-compat-funcall 'directory-abbrev-make-regexp home-dir)
+ filename))
(tramp-make-tramp-file-name
vec (concat "~" (substring filename (match-beginning 1))))
(tramp-make-tramp-file-name (tramp-dissect-file-name filename)))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master a4dd94de80: Don't attempt to connect to a remote server during 'abbreviate-file-name',
Stefan Monnier <=