emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 408818480b6: Tramp cleanup


From: Michael Albinus
Subject: master 408818480b6: Tramp cleanup
Date: Thu, 7 Dec 2023 08:03:00 -0500 (EST)

branch: master
commit 408818480b66f97ffaad80b11f8e3446c2014aeb
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    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.
---
 doc/misc/tramp.texi      |  6 +++---
 lisp/net/tramp-cache.el  |  8 ++++----
 lisp/net/tramp-compat.el |  1 +
 lisp/net/tramp-crypt.el  | 24 +++++++++++++++++++++---
 lisp/net/tramp-sh.el     | 12 ++++++------
 lisp/net/tramp.el        |  6 +++---
 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}}
 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
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."
   (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
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 @@
 ;; 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))))
 
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."
     (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)
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'.")
  (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)
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."
     (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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]