aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2023-12-07 14:02:49 +0100
committerMichael Albinus2023-12-07 14:02:49 +0100
commit408818480b66f97ffaad80b11f8e3446c2014aeb (patch)
treef1a723b39522c1b53ec1bc41bfe574748f930a8f
parent3a7abc7e497e77ba9bc5a71f3836636675dffe6b (diff)
downloademacs-408818480b66f97ffaad80b11f8e3446c2014aeb.tar.gz
emacs-408818480b66f97ffaad80b11f8e3446c2014aeb.zip
Tramp cleanup
* doc/misc/tramp.texi (Remote processes): Adapt index. * lisp/net/tramp.el (tramp-skeleton-directory-files) (tramp-skeleton-make-symbolic-link): * lisp/net/tramp-cache.el (with-tramp-saved-file-property) (with-tramp-saved-file-properties) (with-tramp-saved-connection-property) (with-tramp-saved-connection-properties): Use `setf' but `setq' in macro. * lisp/net/tramp-compat.el (tramp-compat-funcall): Declare debug. * lisp/net/tramp-crypt.el (tramp-crypt-file-name-p): Exclude lock files. (tramp-crypt-file-name-handler-alist): Use `identity' for `abbreviate-file-name'. (tramp-crypt-add-directory, tramp-crypt-remove-directory): Adapt docstrings. (tramp-crypt-cleanup-connection): New defun. Add it to `tramp-cleanup-connection-hook' * lisp/net/tramp-sh.el (tramp-sh-extra-args): Extend regexp.
-rw-r--r--doc/misc/tramp.texi6
-rw-r--r--lisp/net/tramp-cache.el8
-rw-r--r--lisp/net/tramp-compat.el1
-rw-r--r--lisp/net/tramp-crypt.el24
-rw-r--r--lisp/net/tramp-sh.el12
-rw-r--r--lisp/net/tramp.el6
6 files changed, 38 insertions, 19 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index c21426a32f7..5f79c195e42 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -3671,7 +3671,7 @@ ssh@value{postfixhop}you@@remotehost@value{postfix}/path @key{RET}}
3671Each involved method must be an inline method (@pxref{Inline methods}). 3671Each involved method must be an inline method (@pxref{Inline methods}).
3672 3672
3673@value{tramp} adds the ad-hoc definitions on the fly to 3673@value{tramp} adds the ad-hoc definitions on the fly to
3674@code{tramp-default-proxies-alist} and is available for re-use during 3674@code{tramp-default-proxies-alist} and is available for reuse during
3675that Emacs session. Subsequent @value{tramp} connections to the same 3675that Emacs session. Subsequent @value{tramp} connections to the same
3676remote host can then use the shortcut form: 3676remote host can then use the shortcut form:
3677@samp{@trampfn{ssh,you@@remotehost,/path}}. 3677@samp{@trampfn{ssh,you@@remotehost,/path}}.
@@ -4201,7 +4201,7 @@ To open @command{powershell} as a remote shell, use this:
4201 4201
4202@subsection Remote process connection type 4202@subsection Remote process connection type
4203@vindex process-connection-type 4203@vindex process-connection-type
4204@cindex tramp-process-connection-type 4204@vindex tramp-process-connection-type
4205 4205
4206Asynchronous processes behave differently based on whether they use a 4206Asynchronous processes behave differently based on whether they use a
4207pseudo tty or not. This is controlled by the variable 4207pseudo tty or not. This is controlled by the variable
@@ -4338,7 +4338,7 @@ called @code{tramp-connection-local-*-ps-profile} and
4338@end group 4338@end group
4339@end lisp 4339@end lisp
4340 4340
4341@cindex proced 4341@cindex @code{proced}
4342@vindex proced-show-remote-processes 4342@vindex proced-show-remote-processes
4343If you want to see a listing of remote system processes when calling 4343If you want to see a listing of remote system processes when calling
4344@code{proced}, set user option @code{proced-show-remote-processes} to 4344@code{proced}, set user option @code{proced-show-remote-processes} to
diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el
index 6ecb80f09b2..7c4e4d68a14 100644
--- a/lisp/net/tramp-cache.el
+++ b/lisp/net/tramp-cache.el
@@ -340,7 +340,7 @@ Preserve timestamps."
340 (declare (indent 3) (debug t)) 340 (declare (indent 3) (debug t))
341 `(progn 341 `(progn
342 ;; Unify localname. Remove hop from `tramp-file-name' structure. 342 ;; Unify localname. Remove hop from `tramp-file-name' structure.
343 (setq ,key (tramp-file-name-unify ,key ,file)) 343 (setf ,key (tramp-file-name-unify ,key ,file))
344 (let* ((hash (tramp-get-hash-table ,key)) 344 (let* ((hash (tramp-get-hash-table ,key))
345 (cached (and (hash-table-p hash) (gethash ,property hash)))) 345 (cached (and (hash-table-p hash) (gethash ,property hash))))
346 (unwind-protect (progn ,@body) 346 (unwind-protect (progn ,@body)
@@ -358,7 +358,7 @@ Preserve timestamps."
358 (declare (indent 3) (debug t)) 358 (declare (indent 3) (debug t))
359 `(progn 359 `(progn
360 ;; Unify localname. Remove hop from `tramp-file-name' structure. 360 ;; Unify localname. Remove hop from `tramp-file-name' structure.
361 (setq ,key (tramp-file-name-unify ,key ,file)) 361 (setf ,key (tramp-file-name-unify ,key ,file))
362 (let* ((hash (tramp-get-hash-table ,key)) 362 (let* ((hash (tramp-get-hash-table ,key))
363 (values 363 (values
364 (and (hash-table-p hash) 364 (and (hash-table-p hash)
@@ -474,7 +474,7 @@ used to cache connection properties of the local machine."
474 "Save PROPERTY, run BODY, reset PROPERTY." 474 "Save PROPERTY, run BODY, reset PROPERTY."
475 (declare (indent 2) (debug t)) 475 (declare (indent 2) (debug t))
476 `(progn 476 `(progn
477 (setq ,key (tramp-file-name-unify ,key)) 477 (setf ,key (tramp-file-name-unify ,key))
478 (let* ((hash (tramp-get-hash-table ,key)) 478 (let* ((hash (tramp-get-hash-table ,key))
479 (cached (and (hash-table-p hash) 479 (cached (and (hash-table-p hash)
480 (gethash ,property hash tramp-cache-undefined)))) 480 (gethash ,property hash tramp-cache-undefined))))
@@ -491,7 +491,7 @@ used to cache connection properties of the local machine."
491PROPERTIES is a list of file properties (strings)." 491PROPERTIES is a list of file properties (strings)."
492 (declare (indent 2) (debug t)) 492 (declare (indent 2) (debug t))
493 `(progn 493 `(progn
494 (setq ,key (tramp-file-name-unify ,key)) 494 (setf ,key (tramp-file-name-unify ,key))
495 (let* ((hash (tramp-get-hash-table ,key)) 495 (let* ((hash (tramp-get-hash-table ,key))
496 (values 496 (values
497 (mapcar 497 (mapcar
diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el
index 7c10c6530e9..22ee5b32717 100644
--- a/lisp/net/tramp-compat.el
+++ b/lisp/net/tramp-compat.el
@@ -61,6 +61,7 @@
61;; avoid them in cases we know what we do. 61;; avoid them in cases we know what we do.
62(defmacro tramp-compat-funcall (function &rest arguments) 62(defmacro tramp-compat-funcall (function &rest arguments)
63 "Call FUNCTION with ARGUMENTS if it exists. Do not raise compiler warnings." 63 "Call FUNCTION with ARGUMENTS if it exists. Do not raise compiler warnings."
64 (declare (indent 1) (debug t))
64 `(when (functionp ,function) 65 `(when (functionp ,function)
65 (with-no-warnings (funcall ,function ,@arguments)))) 66 (with-no-warnings (funcall ,function ,@arguments))))
66 67
diff --git a/lisp/net/tramp-crypt.el b/lisp/net/tramp-crypt.el
index 587b9db067a..379b8b70656 100644
--- a/lisp/net/tramp-crypt.el
+++ b/lisp/net/tramp-crypt.el
@@ -148,6 +148,8 @@ If NAME doesn't belong to an encrypted remote directory, return nil."
148 (and tramp-crypt-enabled (stringp name) 148 (and tramp-crypt-enabled (stringp name)
149 (not (file-name-quoted-p name)) 149 (not (file-name-quoted-p name))
150 (not (string-suffix-p tramp-crypt-encfs-config name)) 150 (not (string-suffix-p tramp-crypt-encfs-config name))
151 ;; No lock file name.
152 (not (string-prefix-p ".#" (file-name-nondirectory name)))
151 (dolist (dir tramp-crypt-directories) 153 (dolist (dir tramp-crypt-directories)
152 (and (string-prefix-p 154 (and (string-prefix-p
153 dir (file-name-as-directory (expand-file-name name))) 155 dir (file-name-as-directory (expand-file-name name)))
@@ -157,7 +159,7 @@ If NAME doesn't belong to an encrypted remote directory, return nil."
157;; New handlers should be added here. 159;; New handlers should be added here.
158;;;###tramp-autoload 160;;;###tramp-autoload
159(defconst tramp-crypt-file-name-handler-alist 161(defconst tramp-crypt-file-name-handler-alist
160 '(;; `abbreviate-file-name' performed by default handler. 162 '((abbreviate-file-name . identity)
161 (access-file . tramp-crypt-handle-access-file) 163 (access-file . tramp-crypt-handle-access-file)
162 (add-name-to-file . tramp-handle-add-name-to-file) 164 (add-name-to-file . tramp-handle-add-name-to-file)
163 ;; `byte-compiler-base-file-name' performed by default handler. 165 ;; `byte-compiler-base-file-name' performed by default handler.
@@ -492,7 +494,7 @@ See `tramp-crypt-do-encrypt-or-decrypt-file'."
492 494
493;;;###tramp-autoload 495;;;###tramp-autoload
494(defun tramp-crypt-add-directory (name) 496(defun tramp-crypt-add-directory (name)
495 "Mark remote directory NAME for encryption. 497 "Mark expanded remote directory NAME for encryption.
496Files in that directory and all subdirectories will be encrypted 498Files in that directory and all subdirectories will be encrypted
497before copying to, and decrypted after copying from that 499before copying to, and decrypted after copying from that
498directory. File names will be also encrypted." 500directory. File names will be also encrypted."
@@ -516,7 +518,7 @@ directory. File names will be also encrypted."
516 #'tramp-crypt-command-completion-p) 518 #'tramp-crypt-command-completion-p)
517 519
518(defun tramp-crypt-remove-directory (name) 520(defun tramp-crypt-remove-directory (name)
519 "Unmark remote directory NAME for encryption. 521 "Unmark expanded remote directory NAME for encryption.
520Existing files in that directory and its subdirectories will be 522Existing files in that directory and its subdirectories will be
521kept in their encrypted form." 523kept in their encrypted form."
522 ;; (declare (completion tramp-crypt-command-completion-p)) 524 ;; (declare (completion tramp-crypt-command-completion-p))
@@ -853,6 +855,22 @@ WILDCARD is not supported."
853 (tramp-compat-funcall 855 (tramp-compat-funcall
854 'unlock-file (tramp-crypt-encrypt-file-name filename)))) 856 'unlock-file (tramp-crypt-encrypt-file-name filename))))
855 857
858(defun tramp-crypt-cleanup-connection (vec)
859 "Cleanup crypt ressources determined by VEC."
860 (let ((tramp-cleanup-connection-hook
861 (remove
862 #'tramp-crypt-cleanup-connection tramp-cleanup-connection-hook)))
863 (dolist (dir tramp-crypt-directories)
864 (when (tramp-file-name-equal-p vec (tramp-dissect-file-name dir))
865 (tramp-cleanup-connection (tramp-crypt-dissect-file-name dir))))))
866
867;; Add cleanup hooks.
868(add-hook 'tramp-cleanup-connection-hook #'tramp-crypt-cleanup-connection)
869(add-hook 'tramp-crypt-unload-hook
870 (lambda ()
871 (remove-hook 'tramp-cleanup-connection-hook
872 #'tramp-crypt-cleanup-connection)))
873
856(with-eval-after-load 'bookmark 874(with-eval-after-load 'bookmark
857 (add-hook 'bookmark-inhibit-context-functions 875 (add-hook 'bookmark-inhibit-context-functions
858 #'tramp-crypt-file-name-p) 876 #'tramp-crypt-file-name-p)
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 3b47dafcb46..660b5f53a5f 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -521,8 +521,8 @@ The string is used in `tramp-methods'.")
521 (tramp-set-completion-function "fcp" tramp-completion-function-alist-ssh)) 521 (tramp-set-completion-function "fcp" tramp-completion-function-alist-ssh))
522 522
523(defcustom tramp-sh-extra-args 523(defcustom tramp-sh-extra-args
524 `((,(rx "/bash" eos) . "-noediting -norc -noprofile") 524 `((,(rx (| bos "/") "bash" eos) . "-noediting -norc -noprofile")
525 (,(rx "/zsh" eos) . "-f +Z -V")) 525 (,(rx (| bos "/") "zsh" eos) . "-f +Z -V"))
526 "Alist specifying extra arguments to pass to the remote shell. 526 "Alist specifying extra arguments to pass to the remote shell.
527Entries are (REGEXP . ARGS) where REGEXP is a regular expression 527Entries are (REGEXP . ARGS) where REGEXP is a regular expression
528matching the shell file name and ARGS is a string specifying the 528matching the shell file name and ARGS is a string specifying the
@@ -533,7 +533,7 @@ This variable is only used when Tramp needs to start up another shell
533for tilde expansion. The extra arguments should typically prevent the 533for tilde expansion. The extra arguments should typically prevent the
534shell from reading its init file." 534shell from reading its init file."
535 :group 'tramp 535 :group 'tramp
536 :version "27.1" 536 :version "30.1"
537 :type '(alist :key-type regexp :value-type string)) 537 :type '(alist :key-type regexp :value-type string))
538 538
539(defconst tramp-actions-before-shell 539(defconst tramp-actions-before-shell
@@ -2523,7 +2523,7 @@ The method used must be an out-of-band method."
2523 (tramp-get-connection-name v) 2523 (tramp-get-connection-name v)
2524 (tramp-get-connection-buffer v) 2524 (tramp-get-connection-buffer v)
2525 copy-program copy-args))) 2525 copy-program copy-args)))
2526 ;; This is neded for ssh or PuTTY based processes, and 2526 ;; This is needed for ssh or PuTTY based processes, and
2527 ;; only if the respective options are set. Perhaps, 2527 ;; only if the respective options are set. Perhaps,
2528 ;; the setting could be more fine-grained. 2528 ;; the setting could be more fine-grained.
2529 ;; (process-put p 'tramp-shared-socket t) 2529 ;; (process-put p 'tramp-shared-socket t)
@@ -3847,7 +3847,7 @@ Fall back to normal file name handler if no Tramp handler exists."
3847 v 'file-notify-error 3847 v 'file-notify-error
3848 "`%s' failed to start on remote host" 3848 "`%s' failed to start on remote host"
3849 (string-join sequence " ")) 3849 (string-join sequence " "))
3850 ;; This is neded for ssh or PuTTY based processes, and only if 3850 ;; This is needed for ssh or PuTTY based processes, and only if
3851 ;; the respective options are set. Perhaps, the setting could 3851 ;; the respective options are set. Perhaps, the setting could
3852 ;; be more fine-grained. 3852 ;; be more fine-grained.
3853 ;; (process-put p 'tramp-shared-socket t) 3853 ;; (process-put p 'tramp-shared-socket t)
@@ -5255,7 +5255,7 @@ connection if a previous connection has died for some reason."
5255 (and tramp-encoding-command-interactive 5255 (and tramp-encoding-command-interactive
5256 `(,tramp-encoding-command-interactive))))))) 5256 `(,tramp-encoding-command-interactive)))))))
5257 5257
5258 ;; This is neded for ssh or PuTTY based processes, 5258 ;; This is needed for ssh or PuTTY based processes,
5259 ;; and only if the respective options are set. 5259 ;; and only if the respective options are set.
5260 ;; Perhaps, the setting could be more fine-grained. 5260 ;; Perhaps, the setting could be more fine-grained.
5261 ;; (process-put p 'tramp-shared-socket t) 5261 ;; (process-put p 'tramp-shared-socket t)
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 3baad82dda1..88cbfa2d88c 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3328,7 +3328,7 @@ BODY is the backend specific code."
3328 (with-parsed-tramp-file-name (expand-file-name ,directory) nil 3328 (with-parsed-tramp-file-name (expand-file-name ,directory) nil
3329 (tramp-barf-if-file-missing v ,directory 3329 (tramp-barf-if-file-missing v ,directory
3330 (when (file-directory-p ,directory) 3330 (when (file-directory-p ,directory)
3331 (setq ,directory 3331 (setf ,directory
3332 (file-name-as-directory (expand-file-name ,directory))) 3332 (file-name-as-directory (expand-file-name ,directory)))
3333 (let ((temp 3333 (let ((temp
3334 (with-tramp-file-property v localname "directory-files" ,@body)) 3334 (with-tramp-file-property v localname "directory-files" ,@body))
@@ -3499,7 +3499,7 @@ on the same host. Otherwise, TARGET is quoted."
3499 (let ((non-essential t)) 3499 (let ((non-essential t))
3500 (when (and (tramp-tramp-file-p ,target) 3500 (when (and (tramp-tramp-file-p ,target)
3501 (tramp-file-name-equal-p v (tramp-dissect-file-name ,target))) 3501 (tramp-file-name-equal-p v (tramp-dissect-file-name ,target)))
3502 (setq ,target (tramp-file-local-name (expand-file-name ,target)))) 3502 (setf ,target (tramp-file-local-name (expand-file-name ,target))))
3503 ;; There could be a cyclic link. 3503 ;; There could be a cyclic link.
3504 (tramp-flush-file-properties 3504 (tramp-flush-file-properties
3505 v (expand-file-name ,target (tramp-file-local-name default-directory)))) 3505 v (expand-file-name ,target (tramp-file-local-name default-directory))))
@@ -4946,7 +4946,7 @@ a connection-local variable."
4946 ;; Query flag is overwritten in `tramp-post-process-creation', 4946 ;; Query flag is overwritten in `tramp-post-process-creation',
4947 ;; so we reset it. 4947 ;; so we reset it.
4948 (set-process-query-on-exit-flag p (null noquery)) 4948 (set-process-query-on-exit-flag p (null noquery))
4949 ;; This is neded for ssh or PuTTY based processes, and 4949 ;; This is needed for ssh or PuTTY based processes, and
4950 ;; only if the respective options are set. Perhaps, the 4950 ;; only if the respective options are set. Perhaps, the
4951 ;; setting could be more fine-grained. 4951 ;; setting could be more fine-grained.
4952 ;; (process-put p 'tramp-shared-socket t) 4952 ;; (process-put p 'tramp-shared-socket t)