From 4df0f39d3af53f174d22319722ba5cbb7518dbb6 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Tue, 21 May 2024 18:13:40 +0200 Subject: [PATCH] Fix some Tramp oddities * lisp/net/tramp-container.el: Move connection-local settings where they belong to. * lisp/net/tramp-sshfs.el (tramp-connection-properties): Do not set connection property "direct-async-process". (tramp-direct-async-process): Set connection-local value. * test/lisp/net/tramp-tests.el (comp-warn-primitives): Declare. (tramp-test18-file-attributes): Use it. (cherry picked from commit 9aeb4872d473695b75a27184b7e90868c15242c9) --- lisp/net/tramp-container.el | 66 +++++++++++++++++------------------- lisp/net/tramp-sshfs.el | 13 +++++-- test/lisp/net/tramp-tests.el | 4 ++- 3 files changed, 45 insertions(+), 38 deletions(-) diff --git a/lisp/net/tramp-container.el b/lisp/net/tramp-container.el index 3d15d71d709..2886e25d16b 100644 --- a/lisp/net/tramp-container.el +++ b/lisp/net/tramp-container.el @@ -554,7 +554,25 @@ see its function help for a description of the format." (tramp-set-completion-function tramp-kubernetes-method - `((tramp-kubernetes--completion-function ,tramp-kubernetes-method)))) + `((tramp-kubernetes--completion-function ,tramp-kubernetes-method))) + + (defconst tramp-kubernetes-connection-local-default-variables + '((tramp-config-check . tramp-kubernetes--current-context-data) + ;; This variable will be eval'ed in `tramp-expand-args'. + (tramp-extra-expand-args + . (?a (tramp-kubernetes--container (car tramp-current-connection)) + ?h (tramp-kubernetes--pod (car tramp-current-connection)) + ?x (tramp-kubernetes--context-namespace + (car tramp-current-connection))))) + "Default connection-local variables for remote kubernetes connections.") + + (connection-local-set-profile-variables + 'tramp-kubernetes-connection-local-default-profile + tramp-kubernetes-connection-local-default-variables) + + (connection-local-set-profiles + `(:application tramp :protocol ,tramp-kubernetes-method) + 'tramp-kubernetes-connection-local-default-profile)) ;;;###tramp-autoload (defun tramp-enable-toolbox-method () @@ -595,7 +613,19 @@ see its function help for a description of the format." (tramp-set-completion-function tramp-flatpak-method - `((tramp-flatpak--completion-function ,tramp-flatpak-method)))) + `((tramp-flatpak--completion-function ,tramp-flatpak-method))) + + (defconst tramp-flatpak-connection-local-default-variables + `((tramp-remote-path . ,(cons "/app/bin" tramp-remote-path))) + "Default connection-local variables for remote flatpak connections.") + + (connection-local-set-profile-variables + 'tramp-flatpak-connection-local-default-profile + tramp-flatpak-connection-local-default-variables) + + (connection-local-set-profiles + `(:application tramp :protocol ,tramp-flatpak-method) + 'tramp-flatpak-connection-local-default-profile)) ;;;###tramp-autoload (defun tramp-enable-apptainer-method () @@ -638,38 +668,6 @@ see its function help for a description of the format." tramp-nspawn-method `((tramp-nspawn--completion-function ,tramp-nspawn-method)))) -;; Default connection-local variables for Tramp. - -(defconst tramp-kubernetes-connection-local-default-variables - '((tramp-config-check . tramp-kubernetes--current-context-data) - ;; This variable will be eval'ed in `tramp-expand-args'. - (tramp-extra-expand-args - . (?a (tramp-kubernetes--container (car tramp-current-connection)) - ?h (tramp-kubernetes--pod (car tramp-current-connection)) - ?x (tramp-kubernetes--context-namespace - (car tramp-current-connection))))) - "Default connection-local variables for remote kubernetes connections.") - -(connection-local-set-profile-variables - 'tramp-kubernetes-connection-local-default-profile - tramp-kubernetes-connection-local-default-variables) - -(connection-local-set-profiles - `(:application tramp :protocol ,tramp-kubernetes-method) - 'tramp-kubernetes-connection-local-default-profile) - -(defconst tramp-flatpak-connection-local-default-variables - `((tramp-remote-path . ,(cons "/app/bin" tramp-remote-path))) - "Default connection-local variables for remote flatpak connections.") - -(connection-local-set-profile-variables - 'tramp-flatpak-connection-local-default-profile - tramp-flatpak-connection-local-default-variables) - -(connection-local-set-profiles - `(:application tramp :protocol ,tramp-flatpak-method) - 'tramp-flatpak-connection-local-default-profile) - (add-hook 'tramp-unload-hook (lambda () (unload-feature 'tramp-container 'force))) diff --git a/lisp/net/tramp-sshfs.el b/lisp/net/tramp-sshfs.el index d0d56b8967e..218cf30dea5 100644 --- a/lisp/net/tramp-sshfs.el +++ b/lisp/net/tramp-sshfs.el @@ -67,9 +67,6 @@ (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-c")))) - (add-to-list 'tramp-connection-properties - `(,(format "/%s:" tramp-sshfs-method) "direct-async-process" t)) - (tramp-set-completion-function tramp-sshfs-method tramp-completion-function-alist-ssh)) @@ -445,6 +442,16 @@ connection if a previous connection has died for some reason." (with-tramp-connection-property vec "gid-string" (tramp-get-local-gid 'string)))) +;; Default connection-local variables for Tramp. + +(connection-local-set-profile-variables + 'tramp-sshfs-connection-local-default-profile + '((tramp-direct-async-process t))) + +(connection-local-set-profiles + `(:application tramp :protocol ,tramp-sshfs-method) + 'tramp-sshfs-connection-local-default-profile) + ;; `shell-mode' tries to open remote files like "/sshfs:user@host:~/.history". ;; This fails, because the tilde cannot be expanded. Tell ;; `tramp-handle-expand-file-name' to tolerate this. diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 63c1428863d..6932bbdc4fe 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -64,6 +64,7 @@ (declare-function tramp-method-out-of-band-p "tramp-sh") (declare-function tramp-smb-get-localname "tramp-smb") (defvar ange-ftp-make-backup-files) +(defvar comp-warn-primitives) (defvar tramp-connection-properties) (defvar tramp-copy-size-limit) (defvar tramp-fuse-remove-hidden-files) @@ -3689,7 +3690,8 @@ This tests also `access-file', `file-readable-p', ;; `access-file' returns nil in case of success. (should-not (access-file tmp-name1 "error")) ;; `access-file' could use a timeout. - (let ((remote-file-name-access-timeout 1)) + (let ((remote-file-name-access-timeout 1) + comp-warn-primitives) (cl-letf (((symbol-function #'file-exists-p) (lambda (_filename) (sleep-for 5)))) (should-error -- 2.39.5