summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/misc/tramp.texi13
-rw-r--r--lisp/net/tramp-cache.el61
-rw-r--r--lisp/net/tramp-container.el30
3 files changed, 70 insertions, 34 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 0f9ffced90c..81feb56ec31 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -3798,7 +3798,18 @@ completion lists. If you want to suppress this completion because
there are invalid entries in the persistency file, for example if the
host configuration changes often, or if you plug your laptop to
different networks frequently, you can set the user option
-@code{tramp-completion-use-cache} to @code{nil}.
+@code{tramp-completion-use-cache} to @code{nil}. This is set per
+default for all container-based methods, like @option{docker} or
+@option{podman}. If you want to suppress this for other connections,
+you can use the connection property @t{"completion-use-cache"},
+@xref{Predefined connection information}. Example:
+
+@lisp
+@group
+(add-to-list 'tramp-connection-properties
+ (list "^/sshfs:" "completion-use-cache" nil))
+@end group
+@end lisp
After remote host name completion comes completion of file names on
the remote host. It works the same as with local host file completion
diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el
index 2694b8f490a..4ff7d649b42 100644
--- a/lisp/net/tramp-cache.el
+++ b/lisp/net/tramp-cache.el
@@ -73,6 +73,9 @@
;; `tramp-persistency-file-name', although being connection
;; properties related to a `tramp-file-name' structure.
;;
+;; - Properties retrieved from `tramp-connection-properties' are not
+;; saved in the file `tramp-persistency-file-name'.
+;;
;; - Reusable properties, which should not be saved, are kept in the
;; process key retrieved by `tramp-get-process' (the main connection
;; process). Other processes could reuse these properties, avoiding
@@ -86,6 +89,8 @@
(require 'tramp-compat)
(require 'time-stamp)
+(declare-function tramp-get-method-parameter "tramp")
+
;;; -- Cache --
;;;###tramp-autoload
@@ -136,17 +141,20 @@ If it doesn't exist yet, it is created and initialized with
matching entries of `tramp-connection-properties'.
If KEY is `tramp-cache-undefined', don't create anything, and return nil."
;; (declare (tramp-suppress-trace t))
- (unless (eq key tramp-cache-undefined)
- (or (gethash key tramp-cache-data)
- (let ((hash
- (puthash key (make-hash-table :test #'equal) tramp-cache-data)))
- (when (tramp-file-name-p key)
- (dolist (elt tramp-connection-properties)
- (when (string-match-p
- (or (nth 0 elt) "")
- (tramp-make-tramp-file-name key 'noloc))
- (tramp-set-connection-property key (nth 1 elt) (nth 2 elt)))))
- hash))))
+ (let ((tramp-verbose 0))
+ (unless (eq key tramp-cache-undefined)
+ (or (gethash key tramp-cache-data)
+ (let ((hash
+ (puthash key (make-hash-table :test #'equal) tramp-cache-data)))
+ (when (tramp-file-name-p key)
+ (dolist (elt tramp-connection-properties)
+ (when (string-match-p
+ (or (nth 0 elt) "")
+ (tramp-make-tramp-file-name key 'noloc))
+ ;; Mark it as taken from `tramp-connection-properties'.
+ (tramp-set-connection-property
+ key (propertize (nth 1 elt) 'tramp-default t) (nth 2 elt)))))
+ hash)))))
;; We cannot use the `declare' form for `tramp-suppress-trace' in
;; autoloaded functions, because the tramp-loaddefs.el generation
@@ -596,9 +604,14 @@ PROPERTIES is a list of file properties (strings)."
(not (tramp-file-name-localname key))
(not (gethash "login-as" value))
(not (gethash "started" value)))
- (dolist (k (hash-table-keys value))
- (when (string-prefix-p " " k)
- (remhash k value)))
+ (progn
+ (dolist (k (hash-table-keys value))
+ ;; Suppress ephemeral properties.
+ (when (or (string-prefix-p " " k)
+ (get-text-property 0 'tramp-default k))
+ (remhash k value)))
+ (unless (hash-table-keys value)
+ (remhash key cache)))
(remhash key cache)))
cache)
;; Dump it.
@@ -635,15 +648,17 @@ your laptop to different networks frequently."
"Return a list of (user host) tuples allowed to access for METHOD.
This function is added always in `tramp-get-completion-function'
for all methods. Resulting data are derived from connection history."
- (and tramp-completion-use-cache
- (mapcar
- (lambda (key)
- (and (tramp-file-name-p key)
- (string-equal method (tramp-file-name-method key))
- (not (tramp-file-name-localname key))
- (list (tramp-file-name-user key)
- (tramp-file-name-host key))))
- (hash-table-keys tramp-cache-data))))
+ (mapcar
+ (lambda (key)
+ (let ((tramp-verbose 0))
+ (and (tramp-file-name-p key)
+ (string-equal method (tramp-file-name-method key))
+ (not (tramp-file-name-localname key))
+ (tramp-get-method-parameter
+ key 'tramp-completion-use-cache tramp-completion-use-cache)
+ (list (tramp-file-name-user key)
+ (tramp-file-name-host key)))))
+ (hash-table-keys tramp-cache-data)))
;; When "emacs -Q" has been called, both variables are nil. We do not
;; load the persistency file then, in order to have a clean test environment.
diff --git a/lisp/net/tramp-container.el b/lisp/net/tramp-container.el
index 0f1ce71caa3..8429208b44b 100644
--- a/lisp/net/tramp-container.el
+++ b/lisp/net/tramp-container.el
@@ -556,7 +556,8 @@ see its function help for a description of the format."
(tramp-direct-async (,tramp-default-remote-shell "-c"))
(tramp-remote-shell ,tramp-default-remote-shell)
(tramp-remote-shell-login ("-l"))
- (tramp-remote-shell-args ("-i" "-c"))))
+ (tramp-remote-shell-args ("-i" "-c"))
+ (tramp-completion-use-cache nil)))
(add-to-list 'tramp-methods
`(,tramp-dockercp-method
@@ -573,7 +574,8 @@ see its function help for a description of the format."
(tramp-copy-program ,tramp-docker-program)
(tramp-copy-args (("cp")))
(tramp-copy-file-name (("%h" ":") ("%f")))
- (tramp-copy-recursive t)))
+ (tramp-copy-recursive t)
+ (tramp-completion-use-cache nil)))
(add-to-list 'tramp-methods
`(,tramp-podman-method
@@ -586,7 +588,8 @@ see its function help for a description of the format."
(tramp-direct-async (,tramp-default-remote-shell "-c"))
(tramp-remote-shell ,tramp-default-remote-shell)
(tramp-remote-shell-login ("-l"))
- (tramp-remote-shell-args ("-i" "-c"))))
+ (tramp-remote-shell-args ("-i" "-c"))
+ (tramp-completion-use-cache nil)))
(add-to-list 'tramp-methods
`(,tramp-podmancp-method
@@ -603,7 +606,8 @@ see its function help for a description of the format."
(tramp-copy-program ,tramp-podman-program)
(tramp-copy-args (("cp")))
(tramp-copy-file-name (("%h" ":") ("%f")))
- (tramp-copy-recursive t)))
+ (tramp-copy-recursive t)
+ (tramp-completion-use-cache nil)))
(add-to-list 'tramp-methods
`(,tramp-kubernetes-method
@@ -618,7 +622,8 @@ see its function help for a description of the format."
(tramp-direct-async (,tramp-default-remote-shell "-c"))
(tramp-remote-shell ,tramp-default-remote-shell)
(tramp-remote-shell-login ("-l"))
- (tramp-remote-shell-args ("-i" "-c"))))
+ (tramp-remote-shell-args ("-i" "-c"))
+ (tramp-completion-use-cache nil)))
(add-to-list 'tramp-completion-multi-hop-methods tramp-docker-method)
(add-to-list 'tramp-completion-multi-hop-methods tramp-podman-method)
@@ -674,7 +679,8 @@ see its function help for a description of the format."
(tramp-direct-async (,tramp-default-remote-shell "-c"))
(tramp-remote-shell ,tramp-default-remote-shell)
(tramp-remote-shell-login ("-l"))
- (tramp-remote-shell-args ("-c"))))
+ (tramp-remote-shell-args ("-c"))
+ (tramp-completion-use-cache nil)))
(add-to-list 'tramp-default-host-alist `(,tramp-toolbox-method nil ""))
(add-to-list 'tramp-completion-multi-hop-methods tramp-toolbox-method)
@@ -695,7 +701,8 @@ see its function help for a description of the format."
;(tramp-direct-async (,tramp-default-remote-shell "-c"))
(tramp-remote-shell ,tramp-default-remote-shell)
(tramp-remote-shell-login ("-l"))
- (tramp-remote-shell-args ("-c"))))
+ (tramp-remote-shell-args ("-c"))
+ (tramp-completion-use-cache nil)))
(add-to-list 'tramp-completion-multi-hop-methods tramp-distrobox-method)
@@ -719,7 +726,8 @@ see its function help for a description of the format."
(tramp-direct-async (,tramp-default-remote-shell "-c"))
(tramp-remote-shell ,tramp-default-remote-shell)
(tramp-remote-shell-login ("-l"))
- (tramp-remote-shell-args ("-c"))))
+ (tramp-remote-shell-args ("-c"))
+ (tramp-completion-use-cache nil)))
(add-to-list 'tramp-completion-multi-hop-methods tramp-flatpak-method)
@@ -750,7 +758,8 @@ see its function help for a description of the format."
("%h"))) ; Needed for multi-hop check.
(tramp-remote-shell ,tramp-default-remote-shell)
(tramp-remote-shell-login ("-l"))
- (tramp-remote-shell-args ("-c"))))
+ (tramp-remote-shell-args ("-c"))
+ (tramp-completion-use-cache nil)))
(add-to-list 'tramp-completion-multi-hop-methods tramp-apptainer-method)
@@ -771,7 +780,8 @@ see its function help for a description of the format."
("%h")))
(tramp-remote-shell ,tramp-default-remote-shell)
(tramp-remote-shell-login ("-l"))
- (tramp-remote-shell-args ("-i" "-c"))))
+ (tramp-remote-shell-args ("-i" "-c"))
+ (tramp-completion-use-cache nil)))
(add-to-list 'tramp-default-host-alist `(,tramp-nspawn-method nil ".host"))
(add-to-list 'tramp-completion-multi-hop-methods tramp-nspawn-method)