emacs-diffs
[Top][All Lists]
Advanced

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

master 1b806a200ed: Remove further compat code from Tramp


From: Michael Albinus
Subject: master 1b806a200ed: Remove further compat code from Tramp
Date: Sun, 4 Aug 2024 07:24:37 -0400 (EDT)

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

    Remove further compat code from Tramp
    
    * lisp/net/tramp-adb.el (tramp-adb-handle-process-file):
    Use `process-file-return-signal-string'.
    
    * lisp/net/tramp-cache.el (tramp-dump-connection-properties):
    Use "lisp-data" for persistency file.
    
    * lisp/net/tramp-cmds.el (tramp-cleanup-this-connection)
    (tramp-rename-these-files, tramp-recompile-elpa):
    Declare `completion'.
    
    * lisp/net/tramp-container.el (tramp-kubernetes--container)
    (tramp-kubernetes--pod, tramp-kubernetes--namespace): Make more
    robust.
    
    * lisp/net/tramp-crypt.el (tramp-crypt-remove-directory):
    Declare `completion'.
    
    * lisp/net/tramp-gvfs.el (file-notyify-callback): Declare.
    
    * lisp/net/tramp-sh.el (process-file-return-signal-string)
    (vc-handled-backends): Don't declare.
    
    * lisp/net/tramp-smb.el (tramp-smb-handle-copy-directory):
    Use `copy-directory-create-symlink'.
    
    * lisp/net/tramp.el (tramp-skeleton-write-region): Use `lock-file' and
    `unlock-file'..
    (tramp-handle-make-lock-file-name): Use `remote-file-name-inhibit-locks'.
    (tramp-handle-unlock-file): Use `remote-file-name-inhibit-locks'
    and `userlock--handle-unlock-error'.
    (tramp-handle-shell-command): Use `shell-command-buffer-name-async'
    and `shell-command-buffer-name'.
    (tramp-read-passwd): Remove workaround.
---
 lisp/net/tramp-adb.el       |  4 +--
 lisp/net/tramp-cache.el     |  3 +--
 lisp/net/tramp-cmds.el      | 28 ++++----------------
 lisp/net/tramp-container.el | 19 +++++++-------
 lisp/net/tramp-crypt.el     | 12 +++------
 lisp/net/tramp-gvfs.el      |  4 +--
 lisp/net/tramp-message.el   |  5 ++--
 lisp/net/tramp-sh.el        | 11 +++-----
 lisp/net/tramp-smb.el       |  3 +--
 lisp/net/tramp.el           | 63 +++++++++++++++++----------------------------
 10 files changed, 50 insertions(+), 102 deletions(-)

diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 3b8a930cb57..e8bb8ec3184 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -763,9 +763,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
         (kill-buffer (tramp-get-connection-buffer v))
         (setq ret 1)))
 
-      ;; Handle signals.  `process-file-return-signal-string' exists
-      ;; since Emacs 28.1.
-      (when (and (bound-and-true-p process-file-return-signal-string)
+      (when (and process-file-return-signal-string
                 (natnump ret) (> ret 128))
        (setq ret (nth (- ret 128) (tramp-adb-get-signal-strings v))))))
 
diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el
index 9d7fb488412..85a318b8a93 100644
--- a/lisp/net/tramp-cache.el
+++ b/lisp/net/tramp-cache.el
@@ -584,8 +584,7 @@ PROPERTIES is a list of file properties (strings)."
        ;; Dump it.
        (with-temp-file tramp-persistency-file-name
          (insert
-          ;; Starting with Emacs 28, we could use `lisp-data'.
-          (format ";; -*- emacs-lisp -*- <%s %s>\n"
+          (format ";; -*- lisp-data -*- <%s %s>\n"
                   (time-stamp-string "%02y/%02m/%02d %02H:%02M:%02S")
                   tramp-persistency-file-name)
           ";; Tramp connection history.  Don't change this file.\n"
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el
index 866532041c5..3cc8704aaba 100644
--- a/lisp/net/tramp-cmds.el
+++ b/lisp/net/tramp-cmds.el
@@ -157,18 +157,12 @@ When called interactively, a Tramp connection has to be 
selected."
 ;;;###tramp-autoload
 (defun tramp-cleanup-this-connection ()
   "Flush all connection related objects of the current buffer's connection."
-  ;; (declare (completion tramp-command-completion-p)))
+  (declare (completion tramp-command-completion-p))
   (interactive)
   (and (tramp-tramp-file-p default-directory)
        (tramp-cleanup-connection
        (tramp-dissect-file-name default-directory 'noexpand))))
 
-;; Starting with Emacs 28.1, this can be replaced by the "(declare ...)" form.
-;;;###tramp-autoload
-(function-put
- #'tramp-cleanup-this-connection 'completion-predicate
- #'tramp-command-completion-p)
-
 ;;;###tramp-autoload
 (defvar tramp-cleanup-all-connections-hook nil
   "List of functions to be called after all Tramp connections are cleaned up.")
@@ -521,7 +515,7 @@ Interactively, TARGET is selected from 
`tramp-default-rename-alist'
 without confirmation if the prefix argument is non-nil.
 
 For details, see `tramp-rename-files'."
-  ;; (declare (completion tramp-command-completion-p))
+  (declare (completion tramp-command-completion-p))
   (interactive
    (let ((source default-directory)
         target
@@ -552,11 +546,6 @@ For details, see `tramp-rename-files'."
 
   (tramp-rename-files default-directory target))
 
-;; Starting with Emacs 28.1, this can be replaced by the "(declare ...)" form.
-;;;###tramp-autoload
-(function-put
- #'tramp-rename-these-files 'completion-predicate #'tramp-command-completion-p)
-
 ;;; Run as sudo
 
 (defcustom tramp-file-name-with-method "sudo"
@@ -625,9 +614,8 @@ If the buffer runs `dired', the buffer is reverted."
 
 ;;; Recompile on ELPA
 
-;; This function takes action since Emacs 28.1, when
-;; `read-extended-command-predicate' is set to
-;; `command-completion-default-include-p'.
+;; This function takes action, when `read-extended-command-predicate'
+;; is set to `command-completion-default-include-p'.
 ;;;###tramp-autoload
 (defun tramp-recompile-elpa-command-completion-p (_symbol _buffer)
   "A predicate for `tramp-recompile-elpa'.
@@ -642,7 +630,7 @@ Tramp is an installed ELPA package."
 (defun tramp-recompile-elpa ()
   "Recompile the installed Tramp ELPA package.
 This is needed if there are compatibility problems."
-  ;; (declare (completion tramp-recompile-elpa-command-completion-p))
+  (declare (completion tramp-recompile-elpa-command-completion-p))
   (interactive)
   ;; We expect just one Tramp package is installed.
   (when-let
@@ -662,12 +650,6 @@ This is needed if there are compatibility problems."
         "--eval" (format "(byte-recompile-directory %S 0 t)" dir))
        (message "Package `tramp' recompiled.")))))
 
-;; Starting with Emacs 28.1, this can be replaced by the "(declare ...)" form.
-;;;###tramp-autoload
-(function-put
- #'tramp-recompile-elpa 'completion-predicate
- #'tramp-recompile-elpa-command-completion-p)
-
 ;; Tramp version is useful in a number of situations.
 
 ;;;###tramp-autoload
diff --git a/lisp/net/tramp-container.el b/lisp/net/tramp-container.el
index 27bad70753c..57c34a1b8e4 100644
--- a/lisp/net/tramp-container.el
+++ b/lisp/net/tramp-container.el
@@ -339,27 +339,26 @@ see its function help for a description of the format."
 ;;;###tramp-autoload
 (defun tramp-kubernetes--container (vec)
   "Extract the container name from a kubernetes host name in VEC."
-  (or (let ((host (tramp-file-name-host vec)))
-       (and (string-match tramp-kubernetes--host-name-regexp host)
-            (match-string 1 host)))
+  (or (when-let ((host (and vec (tramp-file-name-host vec)))
+                ((string-match tramp-kubernetes--host-name-regexp host)))
+       (match-string 1 host))
       ""))
 
 ;;;###tramp-autoload
 (defun tramp-kubernetes--pod (vec)
   "Extract the pod name from a kubernetes host name in VEC."
-  (or (let ((host (tramp-file-name-host vec)))
-       (and (string-match tramp-kubernetes--host-name-regexp host)
-            (match-string 2 host)))
+  (or (when-let ((host (and vec (tramp-file-name-host vec)))
+                ((string-match tramp-kubernetes--host-name-regexp host)))
+       (match-string 2 host))
       ""))
 
 ;;;###tramp-autoload
 (defun tramp-kubernetes--namespace (vec)
   "Extract the namespace from a kubernetes host name in VEC.
 Use `tramp-kubernetes-namespace' otherwise."
-  (or (when-let ((_ vec)
-                (host (tramp-file-name-host vec)))
-       (and (string-match tramp-kubernetes--host-name-regexp host)
-            (match-string 3 host)))
+  (or (when-let ((host (and vec (tramp-file-name-host vec)))
+                ((string-match tramp-kubernetes--host-name-regexp host)))
+       (match-string 3 host))
       tramp-kubernetes-namespace))
 
 ;; We must change `vec' and `default-directory' to the previous hop,
diff --git a/lisp/net/tramp-crypt.el b/lisp/net/tramp-crypt.el
index e9d9eb2a2c2..2bcdfb061d7 100644
--- a/lisp/net/tramp-crypt.el
+++ b/lisp/net/tramp-crypt.el
@@ -112,9 +112,8 @@ initializing a new encrypted remote directory."
   "Non-nil when encryption support is available.")
 (setq tramp-crypt-enabled (executable-find tramp-crypt-encfs-program))
 
-;; This function takes action since Emacs 28.1, when
-;; `read-extended-command-predicate' is set to
-;; `command-completion-default-include-p'.
+;; This function takes action, when `read-extended-command-predicate'
+;; is set to `command-completion-default-include-p'.
 (defun tramp-crypt-command-completion-p (symbol _buffer)
   "A predicate for Tramp interactive commands.
 They are completed by `M-x TAB' only when encryption support is enabled."
@@ -522,7 +521,7 @@ directory.  File names will be also encrypted."
   "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))
+  (declare (completion tramp-crypt-command-completion-p))
   (interactive "DRemote directory name: ")
   (unless tramp-crypt-enabled
     (tramp-user-error nil "Feature is not enabled"))
@@ -536,11 +535,6 @@ kept in their encrypted form."
     (setq tramp-crypt-directories (delete name tramp-crypt-directories))
     (tramp-register-file-name-handlers)))
 
-;; Starting with Emacs 28.1, this can be replaced by the "(declare ...)" form.
-(function-put
- #'tramp-crypt-remove-directory 'completion-predicate
- #'tramp-crypt-command-completion-p)
-
 ;; `auth-source' requires a user.
 (defun tramp-crypt-dissect-file-name (name)
   "Return a `tramp-file-name' structure for NAME.
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 1f61c5fdd36..6e331396d01 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -108,6 +108,7 @@
 (require 'url-util)
 
 ;; Pacify byte-compiler.
+(declare-function file-notify-callback "filenotify")
 (declare-function zeroconf-init "zeroconf")
 (declare-function zeroconf-list-service-types "zeroconf")
 (declare-function zeroconf-list-services "zeroconf")
@@ -1571,8 +1572,7 @@ If FILE-SYSTEM is non-nil, return file system attributes."
        ;; `unread-command-events' does not accept several events at
        ;; once.  Therefore, we apply the callback directly.
        (when (member action events)
-         (tramp-compat-funcall
-           'file-notify-callback (list proc action file file1)))))
+         (file-notify-callback (list proc action file file1)))))
 
     ;; Save rest of the string.
     (when (string-empty-p string) (setq string nil))
diff --git a/lisp/net/tramp-message.el b/lisp/net/tramp-message.el
index 5e1c9904aa7..901ccc49ad0 100644
--- a/lisp/net/tramp-message.el
+++ b/lisp/net/tramp-message.el
@@ -124,9 +124,8 @@ The outline level is equal to the verbosity of the Tramp 
message."
   (declare (tramp-suppress-trace t))
   (1+ (string-to-number (match-string 3))))
 
-;; This function takes action since Emacs 28.1, when
-;; `read-extended-command-predicate' is set to
-;; `command-completion-default-include-p'.
+;; This function takes action, when `read-extended-command-predicate'
+;; is set to `command-completion-default-include-p'.
 (defun tramp-debug-buffer-command-completion-p (_symbol buffer)
   "A predicate for Tramp interactive commands.
 They are completed by `M-x TAB' only in Tramp debug buffers."
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index b011b7ca3d4..e4e14912579 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -38,9 +38,6 @@
 (declare-function dired-compress-file "dired-aux")
 (declare-function dired-remove-file "dired-aux")
 (defvar dired-compress-file-suffixes)
-;; Added in Emacs 28.1.
-(defvar process-file-return-signal-string)
-(defvar vc-handled-backends)
 (defvar vc-bzr-program)
 (defvar vc-git-program)
 (defvar vc-hg-program)
@@ -2026,8 +2023,7 @@ ID-FORMAT valid values are `string' and `integer'."
        (unless (file-exists-p dirname)
          (tramp-error v 'file-missing dirname))
 
-       ;; `copy-directory-create-symlink' exists since Emacs 28.1.
-       (if (and (bound-and-true-p copy-directory-create-symlink)
+       (if (and copy-directory-create-symlink
                 (setq target (file-symlink-p dirname))
                 (tramp-equal-remote dirname newname))
            (make-symbolic-link
@@ -3288,9 +3284,8 @@ will be used."
         (kill-buffer (tramp-get-connection-buffer v))
         (setq ret 1)))
 
-      ;; Handle signals.  `process-file-return-signal-string' exists
-      ;; since Emacs 28.1.
-      (when (and (bound-and-true-p process-file-return-signal-string)
+      ;; Handle signals.
+      (when (and process-file-return-signal-string
                 (natnump ret) (>= ret 128))
        (setq ret (nth (- ret 128) (tramp-sh-get-signal-strings v)))))))
 
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index 1f4ee8bc8e5..da62773ccc6 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -431,8 +431,7 @@ arguments to pass to the OPERATION."
        (unless (file-exists-p dirname)
          (tramp-error v 'file-missing dirname))
 
-       ;; `copy-directory-create-symlink' exists since Emacs 28.1.
-       (if (and (bound-and-true-p copy-directory-create-symlink)
+       (if (and copy-directory-create-symlink
                 (setq target (file-symlink-p dirname))
                 (tramp-equal-remote dirname newname))
            (make-symbolic-link
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 3260cf5daac..5d6ab3991df 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -2335,26 +2335,22 @@ Must be handled by the callers."
    ((member operation
            '(access-file byte-compiler-base-file-name delete-directory
              delete-file diff-latest-backup-file directory-file-name
-             directory-files directory-files-and-attributes
-             dired-compress-file dired-uncache file-acl
-             file-accessible-directory-p file-attributes
-             file-directory-p file-executable-p file-exists-p
-             file-local-copy file-modes file-name-as-directory
+             directory-files directory-files-and-attributes dired-compress-file
+             dired-uncache file-acl file-accessible-directory-p file-attributes
+             file-directory-p file-executable-p file-exists-p file-local-copy
+             file-locked-p file-modes file-name-as-directory
              file-name-case-insensitive-p file-name-directory
              file-name-nondirectory file-name-sans-versions
-             file-notify-add-watch file-ownership-preserved-p
-             file-readable-p file-regular-p file-remote-p
-             file-selinux-context file-symlink-p file-system-info
-             file-truename file-writable-p find-backup-file-name
-             get-file-buffer insert-directory insert-file-contents
-             load make-directory set-file-acl set-file-modes
-             set-file-selinux-context set-file-times
-             substitute-in-file-name unhandled-file-name-directory
-             vc-registered
+             file-notify-add-watch file-ownership-preserved-p file-readable-p
+             file-regular-p file-remote-p file-selinux-context file-symlink-p
+             file-system-info file-truename file-writable-p
+             find-backup-file-name get-file-buffer
+             insert-directory insert-file-contents load lock-file 
make-directory
+             make-lock-file-name set-file-acl set-file-modes
+             set-file-selinux-context set-file-times substitute-in-file-name
+             unhandled-file-name-directory unlock-file vc-registered
              ;; Emacs 28- only.
              make-directory-internal
-             ;; Emacs 28+ only.
-             file-locked-p lock-file make-lock-file-name unlock-file
              ;; Emacs 29+ only.
              abbreviate-file-name
              ;; Tramp internal magic file name function.
@@ -2699,9 +2695,8 @@ Run BODY."
 
 ;;; File name handler functions for completion mode:
 
-;; This function takes action since Emacs 28.1, when
-;; `read-extended-command-predicate' is set to
-;; `command-completion-default-include-p'.
+;; This function takes action, when `read-extended-command-predicate'
+;; is set to `command-completion-default-include-p'.
 (defun tramp-command-completion-p (_symbol buffer)
   "A predicate for Tramp interactive commands.
 They are completed by `M-x TAB' only if the current buffer is remote."
@@ -3823,8 +3818,7 @@ BODY is the backend specific code."
                      (tramp-tramp-file-p lockname)
                      (not file-locked))
             (setq file-locked t)
-            ;; `lock-file' exists since Emacs 28.1.
-            (tramp-compat-funcall 'lock-file lockname))
+            (lock-file lockname))
 
           ;; The body.
           ,@body
@@ -3862,8 +3856,7 @@ BODY is the backend specific code."
 
             ;; Unlock file.
             (when file-locked
-              ;; `unlock-file' exists since Emacs 28.1.
-              (tramp-compat-funcall 'unlock-file lockname))
+              (unlock-file lockname))
 
             ;; Sanity check.
             (unless (equal curbuf (current-buffer))
@@ -4825,8 +4818,7 @@ Do not set it manually, it is used buffer-local in 
`tramp-get-lock-pid'.")
 (defun tramp-handle-make-lock-file-name (file)
   "Like `make-lock-file-name' for Tramp files."
   (and create-lockfiles
-       ;; This variable has been introduced with Emacs 28.1.
-       (not (bound-and-true-p remote-file-name-inhibit-locks))
+       (not remote-file-name-inhibit-locks)
        (tramp-run-real-handler 'make-lock-file-name (list file))))
 
 (defun tramp-handle-unlock-file (file)
@@ -4844,12 +4836,10 @@ Do not set it manually, it is used buffer-local in 
`tramp-get-lock-pid'.")
        (unless (or (not create-lockfiles)
                    (bound-and-true-p remote-file-name-inhibit-locks))
          (signal 'file-error `("Cannot remove lock file for" ,file))))
-    ;; `userlock--handle-unlock-error' exists since Emacs 28.1.  It
-    ;; checks for `create-lockfiles' since Emacs 30.1, we don't need
-    ;; this check here, then.
-    (error (unless (or (not create-lockfiles)
-                       (bound-and-true-p remote-file-name-inhibit-locks))
-             (tramp-compat-funcall 'userlock--handle-unlock-error err)))))
+    ;; `userlock--handle-unlock-error' checks for `create-lockfiles'
+    ;; since Emacs 30.1, we don't need this check here, then.
+    (error (unless (or (not create-lockfiles) remote-file-name-inhibit-locks)
+             (userlock--handle-unlock-error err)))))
 
 (defun tramp-handle-load (file &optional noerror nomessage nosuffix 
must-suffix)
   "Like `load' for Tramp files."
@@ -5312,12 +5302,9 @@ support symbolic links."
            (setq current-buffer-p t)
            (current-buffer))
           (t (get-buffer-create
-              ;; These variables have been introduced with Emacs 28.1.
               (if asynchronous
-                  (or (bound-and-true-p shell-command-buffer-name-async)
-                      "*Async Shell Command*")
-                (or (bound-and-true-p shell-command-buffer-name)
-                    "*Shell Command Output*"))))))
+                  (or shell-command-buffer-name-async "*Async Shell Command*")
+                (or shell-command-buffer-name "*Shell Command Output*"))))))
         (error-buffer
          (cond
           ((bufferp error-buffer) error-buffer)
@@ -6849,10 +6836,6 @@ Consults the auth-source package."
                 (lambda () (password-cache-add key auth-passwd)))
           auth-passwd))
 
-      ;; Workaround.  Prior Emacs 28.1, auth-source has saved empty
-      ;; passwords.  See discussion in Bug#50399.
-      (when (tramp-string-empty-or-nil-p auth-passwd)
-       (setq tramp-password-save-function nil))
       (tramp-set-connection-property vec "first-password-request" nil))))
 
 (defun tramp-read-passwd-without-cache (proc &optional prompt)



reply via email to

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