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.
This commit is contained in:
Michael Albinus 2023-12-07 14:02:49 +01:00
parent 3a7abc7e49
commit 408818480b
6 changed files with 38 additions and 19 deletions

View file

@ -3671,7 +3671,7 @@ ssh@value{postfixhop}you@@remotehost@value{postfix}/path @key{RET}}
Each involved method must be an inline method (@pxref{Inline methods}).
@value{tramp} adds the ad-hoc definitions on the fly to
@code{tramp-default-proxies-alist} and is available for re-use during
@code{tramp-default-proxies-alist} and is available for reuse during
that Emacs session. Subsequent @value{tramp} connections to the same
remote host can then use the shortcut form:
@samp{@trampfn{ssh,you@@remotehost,/path}}.
@ -4201,7 +4201,7 @@ To open @command{powershell} as a remote shell, use this:
@subsection Remote process connection type
@vindex process-connection-type
@cindex tramp-process-connection-type
@vindex tramp-process-connection-type
Asynchronous processes behave differently based on whether they use a
pseudo tty or not. This is controlled by the variable
@ -4338,7 +4338,7 @@ called @code{tramp-connection-local-*-ps-profile} and
@end group
@end lisp
@cindex proced
@cindex @code{proced}
@vindex proced-show-remote-processes
If you want to see a listing of remote system processes when calling
@code{proced}, set user option @code{proced-show-remote-processes} to

View file

@ -340,7 +340,7 @@ Preserve timestamps."
(declare (indent 3) (debug t))
`(progn
;; Unify localname. Remove hop from `tramp-file-name' structure.
(setq ,key (tramp-file-name-unify ,key ,file))
(setf ,key (tramp-file-name-unify ,key ,file))
(let* ((hash (tramp-get-hash-table ,key))
(cached (and (hash-table-p hash) (gethash ,property hash))))
(unwind-protect (progn ,@body)
@ -358,7 +358,7 @@ Preserve timestamps."
(declare (indent 3) (debug t))
`(progn
;; Unify localname. Remove hop from `tramp-file-name' structure.
(setq ,key (tramp-file-name-unify ,key ,file))
(setf ,key (tramp-file-name-unify ,key ,file))
(let* ((hash (tramp-get-hash-table ,key))
(values
(and (hash-table-p hash)
@ -474,7 +474,7 @@ used to cache connection properties of the local machine."
"Save PROPERTY, run BODY, reset PROPERTY."
(declare (indent 2) (debug t))
`(progn
(setq ,key (tramp-file-name-unify ,key))
(setf ,key (tramp-file-name-unify ,key))
(let* ((hash (tramp-get-hash-table ,key))
(cached (and (hash-table-p hash)
(gethash ,property hash tramp-cache-undefined))))
@ -491,7 +491,7 @@ used to cache connection properties of the local machine."
PROPERTIES is a list of file properties (strings)."
(declare (indent 2) (debug t))
`(progn
(setq ,key (tramp-file-name-unify ,key))
(setf ,key (tramp-file-name-unify ,key))
(let* ((hash (tramp-get-hash-table ,key))
(values
(mapcar

View file

@ -61,6 +61,7 @@
;; avoid them in cases we know what we do.
(defmacro tramp-compat-funcall (function &rest arguments)
"Call FUNCTION with ARGUMENTS if it exists. Do not raise compiler warnings."
(declare (indent 1) (debug t))
`(when (functionp ,function)
(with-no-warnings (funcall ,function ,@arguments))))

View file

@ -148,6 +148,8 @@ If NAME doesn't belong to an encrypted remote directory, return nil."
(and tramp-crypt-enabled (stringp name)
(not (file-name-quoted-p name))
(not (string-suffix-p tramp-crypt-encfs-config name))
;; No lock file name.
(not (string-prefix-p ".#" (file-name-nondirectory name)))
(dolist (dir tramp-crypt-directories)
(and (string-prefix-p
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."
;; New handlers should be added here.
;;;###tramp-autoload
(defconst tramp-crypt-file-name-handler-alist
'(;; `abbreviate-file-name' performed by default handler.
'((abbreviate-file-name . identity)
(access-file . tramp-crypt-handle-access-file)
(add-name-to-file . tramp-handle-add-name-to-file)
;; `byte-compiler-base-file-name' performed by default handler.
@ -492,7 +494,7 @@ See `tramp-crypt-do-encrypt-or-decrypt-file'."
;;;###tramp-autoload
(defun tramp-crypt-add-directory (name)
"Mark remote directory NAME for encryption.
"Mark expanded remote directory NAME for encryption.
Files in that directory and all subdirectories will be encrypted
before copying to, and decrypted after copying from that
directory. File names will be also encrypted."
@ -516,7 +518,7 @@ directory. File names will be also encrypted."
#'tramp-crypt-command-completion-p)
(defun tramp-crypt-remove-directory (name)
"Unmark remote directory NAME for encryption.
"Unmark expanded remote directory NAME for encryption.
Existing files in that directory and its subdirectories will be
kept in their encrypted form."
;; (declare (completion tramp-crypt-command-completion-p))
@ -853,6 +855,22 @@ WILDCARD is not supported."
(tramp-compat-funcall
'unlock-file (tramp-crypt-encrypt-file-name filename))))
(defun tramp-crypt-cleanup-connection (vec)
"Cleanup crypt ressources determined by VEC."
(let ((tramp-cleanup-connection-hook
(remove
#'tramp-crypt-cleanup-connection tramp-cleanup-connection-hook)))
(dolist (dir tramp-crypt-directories)
(when (tramp-file-name-equal-p vec (tramp-dissect-file-name dir))
(tramp-cleanup-connection (tramp-crypt-dissect-file-name dir))))))
;; Add cleanup hooks.
(add-hook 'tramp-cleanup-connection-hook #'tramp-crypt-cleanup-connection)
(add-hook 'tramp-crypt-unload-hook
(lambda ()
(remove-hook 'tramp-cleanup-connection-hook
#'tramp-crypt-cleanup-connection)))
(with-eval-after-load 'bookmark
(add-hook 'bookmark-inhibit-context-functions
#'tramp-crypt-file-name-p)

View file

@ -521,8 +521,8 @@ The string is used in `tramp-methods'.")
(tramp-set-completion-function "fcp" tramp-completion-function-alist-ssh))
(defcustom tramp-sh-extra-args
`((,(rx "/bash" eos) . "-noediting -norc -noprofile")
(,(rx "/zsh" eos) . "-f +Z -V"))
`((,(rx (| bos "/") "bash" eos) . "-noediting -norc -noprofile")
(,(rx (| bos "/") "zsh" eos) . "-f +Z -V"))
"Alist specifying extra arguments to pass to the remote shell.
Entries are (REGEXP . ARGS) where REGEXP is a regular expression
matching 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
for tilde expansion. The extra arguments should typically prevent the
shell from reading its init file."
:group 'tramp
:version "27.1"
:version "30.1"
:type '(alist :key-type regexp :value-type string))
(defconst tramp-actions-before-shell
@ -2523,7 +2523,7 @@ The method used must be an out-of-band method."
(tramp-get-connection-name v)
(tramp-get-connection-buffer v)
copy-program copy-args)))
;; This is neded for ssh or PuTTY based processes, and
;; This is needed for ssh or PuTTY based processes, and
;; only if the respective options are set. Perhaps,
;; the setting could be more fine-grained.
;; (process-put p 'tramp-shared-socket t)
@ -3847,7 +3847,7 @@ Fall back to normal file name handler if no Tramp handler exists."
v 'file-notify-error
"`%s' failed to start on remote host"
(string-join sequence " "))
;; This is neded for ssh or PuTTY based processes, and only if
;; This is needed for ssh or PuTTY based processes, and only if
;; the respective options are set. Perhaps, the setting could
;; be more fine-grained.
;; (process-put p 'tramp-shared-socket t)
@ -5255,7 +5255,7 @@ connection if a previous connection has died for some reason."
(and tramp-encoding-command-interactive
`(,tramp-encoding-command-interactive)))))))
;; This is neded for ssh or PuTTY based processes,
;; This is needed for ssh or PuTTY based processes,
;; and only if the respective options are set.
;; Perhaps, the setting could be more fine-grained.
;; (process-put p 'tramp-shared-socket t)

View file

@ -3328,7 +3328,7 @@ BODY is the backend specific code."
(with-parsed-tramp-file-name (expand-file-name ,directory) nil
(tramp-barf-if-file-missing v ,directory
(when (file-directory-p ,directory)
(setq ,directory
(setf ,directory
(file-name-as-directory (expand-file-name ,directory)))
(let ((temp
(with-tramp-file-property v localname "directory-files" ,@body))
@ -3499,7 +3499,7 @@ on the same host. Otherwise, TARGET is quoted."
(let ((non-essential t))
(when (and (tramp-tramp-file-p ,target)
(tramp-file-name-equal-p v (tramp-dissect-file-name ,target)))
(setq ,target (tramp-file-local-name (expand-file-name ,target))))
(setf ,target (tramp-file-local-name (expand-file-name ,target))))
;; There could be a cyclic link.
(tramp-flush-file-properties
v (expand-file-name ,target (tramp-file-local-name default-directory))))
@ -4946,7 +4946,7 @@ a connection-local variable."
;; Query flag is overwritten in `tramp-post-process-creation',
;; so we reset it.
(set-process-query-on-exit-flag p (null noquery))
;; This is neded for ssh or PuTTY based processes, and
;; This is needed for ssh or PuTTY based processes, and
;; only if the respective options are set. Perhaps, the
;; setting could be more fine-grained.
;; (process-put p 'tramp-shared-socket t)