]> git.eshelyaron.com Git - emacs.git/commitdiff
Remove Tramp's `dired-compress-file' handler, not needed anymore
authorMichael Albinus <michael.albinus@gmx.de>
Sat, 13 Nov 2021 14:14:02 +0000 (15:14 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Sat, 13 Nov 2021 14:14:02 +0000 (15:14 +0100)
* lisp/dired-aux.el (dired-check-process, dired-shell-command):
Call `dired-uncache'.
(dired-compress-file): Use `file-local-name'.

* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist):
* lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist):
Remove superfluous comment.

* lisp/net/tramp-sh.el (dired-compress-file): Declare.
(tramp-sh-handle-dired-compress-file): Call real handler for
Emacs >= 29.

* lisp/net/tramp.el (tramp-file-name-for-operation): Reorder list.

* test/lisp/net/tramp-tests.el (tramp-test45-dired-compress-file)
(tramp-test45-dired-compress-dir): Adapt comment.

13 files changed:
lisp/dired-aux.el
lisp/icomplete.el
lisp/net/tramp-adb.el
lisp/net/tramp-archive.el
lisp/net/tramp-crypt.el
lisp/net/tramp-gvfs.el
lisp/net/tramp-rclone.el
lisp/net/tramp-sh.el
lisp/net/tramp-smb.el
lisp/net/tramp-sshfs.el
lisp/net/tramp-sudoedit.el
lisp/net/tramp.el
test/lisp/net/tramp-tests.el

index 7d81d45326ffb60e26a979cff9f2fe6b9fb61300..92409db33ea25ef4bad76e2f86ec836e2530c3ed 100644 (file)
@@ -1007,6 +1007,7 @@ Else returns nil for success."
       (erase-buffer)
       (setq default-directory dir      ; caller's default-directory
            err (not (eq 0 (apply #'process-file program nil t nil arguments))))
+      (dired-uncache dir)
       (if err
          (progn
            (dired-log (concat program " " (prin1-to-string arguments) "\n"))
@@ -1032,6 +1033,7 @@ Return the result of `process-file' - zero for success."
                    nil
                    shell-command-switch
                    cmd)))
+        (dired-uncache dir)
         (unless (zerop res)
           (pop-to-buffer out-buffer))
         res))))
@@ -1280,9 +1282,9 @@ Return nil if no change in files."
                (prog1 (setq newname (file-name-as-directory newname))
                  (dired-shell-command
                   (replace-regexp-in-string
-                   "%o" (shell-quote-argument newname)
+                   "%o" (shell-quote-argument (file-local-name newname))
                    (replace-regexp-in-string
-                    "%i" (shell-quote-argument file)
+                    "%i" (shell-quote-argument (file-local-name file))
                     command
                     nil t)
                    nil t)))
@@ -1293,10 +1295,10 @@ Return nil if no change in files."
                            (dired-check-process msg
                                                 (substring command 0 match)
                                                 (substring command (1+ match))
-                                                file)
+                                                (file-local-name file))
                          (dired-check-process msg
                                               command
-                                              file))
+                                              (file-local-name file)))
                  newname))))
           (t
            ;; We don't recognize the file as compressed, so compress it.
@@ -1314,7 +1316,8 @@ Return nil if no change in files."
                                (default-directory (file-name-directory file)))
                            (dired-shell-command
                             (replace-regexp-in-string
-                             "%o" (shell-quote-argument out-name)
+                             "%o" (shell-quote-argument
+                                   (file-local-name out-name))
                              (replace-regexp-in-string
                               "%i" (shell-quote-argument
                                     (file-name-nondirectory file))
@@ -1344,9 +1347,10 @@ see `dired-compress-file-alist' for the supported suffixes list"
                                 out-name)))
                           (dired-shell-command
                            (replace-regexp-in-string
-                            "%o" (shell-quote-argument out-name)
+                            "%o" (shell-quote-argument
+                                  (file-local-name out-name))
                             (replace-regexp-in-string
-                             "%i" (shell-quote-argument file)
+                             "%i" (shell-quote-argument (file-local-name file))
                              (cdr rule)
                              nil t)
                             nil t))
@@ -1361,7 +1365,8 @@ see `dired-compress-file-alist' for the supported suffixes list"
                             out-name)))))
              (file-error
               (if (not (dired-check-process (concat "Compressing " file)
-                                            "compress" "-f" file))
+                                            "compress" "-f"
+                                            (file-local-name file)))
                   ;; Don't use NEWNAME with `compress'.
                   (concat file ".Z"))))))))
 \f
index f909a3b17712c933175db0da38959c6266ded4f6..8ead8a6217c252ab88a0ac5705336529ab5d24f6 100644 (file)
@@ -418,7 +418,7 @@ if that doesn't produce a completion match."
                 icomplete-show-matches-on-no-input t
                 icomplete-hide-common-prefix nil
                 icomplete-scroll (not (null icomplete-vertical-mode))
-                completion-styles '(flex)
+                completion-styles '(flex basic)
                 completion-flex-nospace nil
                 completion-category-defaults nil
                 completion-ignore-case t
index 374e5db58794e28f1ff4454b765361d78e45cfa8..895543d6db92758982db0544b64c244189aab1f6 100644 (file)
@@ -119,7 +119,6 @@ It is used for TCP/IP devices."
     (directory-files . tramp-handle-directory-files)
     (directory-files-and-attributes
      . tramp-adb-handle-directory-files-and-attributes)
-    ;; Starting with Emacs 29.1, `dired-compress-file' isn't magic anymore.
     (dired-compress-file . ignore)
     (dired-uncache . tramp-handle-dired-uncache)
     (exec-path . tramp-adb-handle-exec-path)
index 578f9fcf913cd4dbb6b10e8e4e882c11e02fa99a..3e0d876dd9ef504489492c4d48b8f2ffac7834fd 100644 (file)
@@ -223,7 +223,6 @@ It must be supported by libarchive(3).")
     (directory-files . tramp-handle-directory-files)
     (directory-files-and-attributes
      . tramp-handle-directory-files-and-attributes)
-    ;; Starting with Emacs 29.1, `dired-compress-file' isn't magic anymore.
     (dired-compress-file . tramp-archive-handle-not-implemented)
     (dired-uncache . tramp-archive-handle-dired-uncache)
     (exec-path . ignore)
index f431f975633003a0a642141d7642cef5a9c731cf..42b67ac7a8e33e3aafe2e14e13d11c821b4a6d7d 100644 (file)
@@ -169,7 +169,6 @@ If NAME doesn't belong to a crypted remote directory, retun nil."
     (directory-files . tramp-crypt-handle-directory-files)
     (directory-files-and-attributes
      . tramp-handle-directory-files-and-attributes)
-    ;; Starting with Emacs 29.1, `dired-compress-file' isn't magic anymore.
     (dired-compress-file . ignore)
     (dired-uncache . tramp-handle-dired-uncache)
     (exec-path . ignore)
index 11de71aa0d91f7944933ea8c930ecb3bb08ff46c..220ce63c0f7daca49aa5b1c1e5e653f86c9bcb6c 100644 (file)
@@ -756,7 +756,6 @@ It has been changed in GVFS 1.14.")
     (directory-files . tramp-handle-directory-files)
     (directory-files-and-attributes
      . tramp-handle-directory-files-and-attributes)
-    ;; Starting with Emacs 29.1, `dired-compress-file' isn't magic anymore.
     (dired-compress-file . ignore)
     (dired-uncache . tramp-handle-dired-uncache)
     (exec-path . ignore)
index c997215a15be7ec536bc3195bb4343495269485f..28a1c01aa61ff3d7950c92859a37a26bdf7f93bc 100644 (file)
@@ -83,7 +83,6 @@
     (directory-files . tramp-fuse-handle-directory-files)
     (directory-files-and-attributes
      . tramp-handle-directory-files-and-attributes)
-    ;; Starting with Emacs 29.1, `dired-compress-file' isn't magic anymore.
     (dired-compress-file . ignore)
     (dired-uncache . tramp-handle-dired-uncache)
     (exec-path . ignore)
index 533ddcf66eac2fb752477499678c4aa3789ef605..c61025a86b25c4b8e1c404a912170c87902eed24 100644 (file)
@@ -34,6 +34,8 @@
 (eval-when-compile (require 'cl-lib))
 (require 'tramp)
 
+;; `dired-*' declarations can be removed, starting with Emacs 29.1.
+(declare-function dired-compress-file "dired-aux")
 (declare-function dired-remove-file "dired-aux")
 (defvar dired-compress-file-suffixes)
 (defvar process-file-return-signal-string)
@@ -952,7 +954,8 @@ Format specifiers \"%s\" are replaced before the script is used.")
     (directory-files . tramp-handle-directory-files)
     (directory-files-and-attributes
      . tramp-sh-handle-directory-files-and-attributes)
-    ;; Starting with Emacs 29.1, `dired-compress-file' isn't magic anymore.
+    ;; Starting with Emacs 29.1, `dired-compress-file' performed by
+    ;; default handler.
     (dired-compress-file . tramp-sh-handle-dired-compress-file)
     (dired-uncache . tramp-handle-dired-uncache)
     (exec-path . tramp-sh-handle-exec-path)
@@ -2472,57 +2475,60 @@ The method used must be an out-of-band method."
 
 ;; Dired.
 
-;; Starting with Emacs 29.1, `dired-compress-file' isn't magic anymore.
 (defun tramp-sh-handle-dired-compress-file (file)
   "Like `dired-compress-file' for Tramp files."
-  ;; Code stolen mainly from dired-aux.el.
-  (with-parsed-tramp-file-name file nil
-    (tramp-flush-file-properties v localname)
-    (let ((suffixes dired-compress-file-suffixes)
-         suffix)
-      ;; See if any suffix rule matches this file name.
-      (while suffixes
-       (let (case-fold-search)
-         (if (string-match-p (car (car suffixes)) localname)
-             (setq suffix (car suffixes) suffixes nil))
-         (setq suffixes (cdr suffixes))))
-
-      (cond ((file-symlink-p file) nil)
-           ((and suffix (nth 2 suffix))
-            ;; We found an uncompression rule.
-            (with-tramp-progress-reporter
-                 v 0 (format "Uncompressing %s" file)
-              (when (tramp-send-command-and-check
-                     v (if (string-match-p "%[io]" (nth 2 suffix))
-                            (replace-regexp-in-string
-                             "%i" (tramp-shell-quote-argument localname)
-                             (nth 2 suffix))
-                          (concat (nth 2 suffix) " "
-                                  (tramp-shell-quote-argument localname))))
-                (unless (string-match-p "\\.tar\\.gz" file)
-                   (dired-remove-file file))
-                (string-match (car suffix) file)
-                (concat (substring file 0 (match-beginning 0))))))
-           (t
-            ;; We don't recognize the file as compressed, so compress it.
-            ;; Try gzip.
-            (with-tramp-progress-reporter v 0 (format "Compressing %s" file)
-              (when (tramp-send-command-and-check
-                     v (if (file-directory-p file)
-                            (format "tar -cf - %s | gzip -c9 > %s.tar.gz"
-                                    (tramp-shell-quote-argument
-                                     (file-name-nondirectory localname))
-                                    (tramp-shell-quote-argument localname))
-                          (concat "gzip -f "
-                                 (tramp-shell-quote-argument localname))))
-                (unless (file-directory-p file)
-                   (dired-remove-file file))
-                (catch 'found nil
-                        (dolist (target (mapcar (lambda (suffix)
-                                                  (concat file suffix))
-                                                '(".tar.gz" ".gz" ".z")))
-                          (when (file-exists-p target)
-                            (throw 'found target)))))))))))
+  ;; Starting with Emacs 29.1, `dired-compress-file' is performed by
+  ;; default handler.
+  (if (>= emacs-major-version 29)
+      (tramp-run-real-handler #'dired-compress-file (list file))
+    ;; Code stolen mainly from dired-aux.el.
+    (with-parsed-tramp-file-name file nil
+      (tramp-flush-file-properties v localname)
+      (let ((suffixes dired-compress-file-suffixes)
+           suffix)
+       ;; See if any suffix rule matches this file name.
+       (while suffixes
+         (let (case-fold-search)
+           (if (string-match-p (car (car suffixes)) localname)
+               (setq suffix (car suffixes) suffixes nil))
+           (setq suffixes (cdr suffixes))))
+
+       (cond ((file-symlink-p file) nil)
+             ((and suffix (nth 2 suffix))
+              ;; We found an uncompression rule.
+              (with-tramp-progress-reporter
+                   v 0 (format "Uncompressing %s" file)
+                (when (tramp-send-command-and-check
+                       v (if (string-match-p "%[io]" (nth 2 suffix))
+                              (replace-regexp-in-string
+                               "%i" (tramp-shell-quote-argument localname)
+                               (nth 2 suffix))
+                            (concat (nth 2 suffix) " "
+                                    (tramp-shell-quote-argument localname))))
+                  (unless (string-match-p "\\.tar\\.gz" file)
+                     (dired-remove-file file))
+                  (string-match (car suffix) file)
+                  (concat (substring file 0 (match-beginning 0))))))
+             (t
+              ;; We don't recognize the file as compressed, so
+              ;; compress it.  Try gzip.
+              (with-tramp-progress-reporter v 0 (format "Compressing %s" file)
+                (when (tramp-send-command-and-check
+                       v (if (file-directory-p file)
+                              (format "tar -cf - %s | gzip -c9 > %s.tar.gz"
+                                      (tramp-shell-quote-argument
+                                       (file-name-nondirectory localname))
+                                      (tramp-shell-quote-argument localname))
+                            (concat "gzip -f "
+                                   (tramp-shell-quote-argument localname))))
+                  (unless (file-directory-p file)
+                     (dired-remove-file file))
+                  (catch 'found nil
+                          (dolist (target (mapcar (lambda (suffix)
+                                                    (concat file suffix))
+                                                  '(".tar.gz" ".gz" ".z")))
+                            (when (file-exists-p target)
+                              (throw 'found target))))))))))))
 
 (defun tramp-sh-handle-insert-directory
     (filename switches &optional wildcard full-directory-p)
index ac567dc07470d9af402d682a7ce0750bb8e59d00..0b25164902e03e57f6eadc061e15985929c7ea10 100644 (file)
@@ -234,7 +234,6 @@ See `tramp-actions-before-shell' for more info.")
     (directory-files . tramp-smb-handle-directory-files)
     (directory-files-and-attributes
      . tramp-handle-directory-files-and-attributes)
-    ;; Starting with Emacs 29.1, `dired-compress-file' isn't magic anymore.
     (dired-compress-file . ignore)
     (dired-uncache . tramp-handle-dired-uncache)
     (exec-path . ignore)
index fc77d998aa60fd9f7363d64ad0db869ee5cf8a5c..a9d8dc933b3b9c28d996cf5bfce79aafea95fb84 100644 (file)
@@ -83,7 +83,6 @@
     (directory-files . tramp-fuse-handle-directory-files)
     (directory-files-and-attributes
      . tramp-handle-directory-files-and-attributes)
-    ;; Starting with Emacs 29.1, `dired-compress-file' isn't magic anymore.
     (dired-compress-file . ignore)
     (dired-uncache . tramp-handle-dired-uncache)
     (exec-path . tramp-sshfs-handle-exec-path)
index 842990488efaa952351aa302445ba4874e6493a7..7cf0ea451d2eb1e341bfb88ed2b3d38ac22dd147 100644 (file)
@@ -75,7 +75,6 @@ See `tramp-actions-before-shell' for more info.")
     (directory-files . tramp-handle-directory-files)
     (directory-files-and-attributes
      . tramp-handle-directory-files-and-attributes)
-    ;; Starting with Emacs 29.1, `dired-compress-file' isn't magic anymore.
     (dired-compress-file . ignore)
     (dired-uncache . tramp-handle-dired-uncache)
     (exec-path . ignore)
index f4493608a46208e500b54d316d64459a78782381..876bbb2c5452b2559fabd4b4930e4cbe7ba79ad7 100644 (file)
@@ -2476,28 +2476,25 @@ Must be handled by the callers."
            '(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-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 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-truename file-writable-p
-             find-backup-file-name get-file-buffer insert-directory
-             insert-file-contents load make-directory
-             make-directory-internal set-file-acl set-file-modes
-             set-file-selinux-context set-file-times
+             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
+             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-truename
+             file-writable-p find-backup-file-name get-file-buffer
+             insert-directory insert-file-contents load
+             make-directory make-directory-internal set-file-acl
+             set-file-modes set-file-selinux-context set-file-times
              substitute-in-file-name unhandled-file-name-directory
              vc-registered
              ;; Emacs 27+ only.
              file-system-info
              ;; Emacs 28+ only.
              file-locked-p lock-file make-lock-file-name unlock-file
-             ;; Starting with Emacs 29.1, `dired-compress-file' isn't
-             ;; magic anymore.
-             dired-compress-file
              ;; Tramp internal magic file name function.
              tramp-set-file-uid-gid))
     (if (file-name-absolute-p (nth 0 args))
index 397e707f13649726382d28a7b88d11a2907b8904..52c6159dc12f425c683d00719160ed5712828fd1 100644 (file)
@@ -6935,7 +6935,8 @@ process sentinels.  They shall not disturb each other."
   (skip-unless (tramp--test-enabled))
   (skip-unless (tramp--test-sh-p))
   (skip-unless (not (tramp--test-crypt-p)))
-  ;; Starting with Emacs 29.1, `dired-compress-file' isn't magic anymore.
+  ;; Starting with Emacs 29.1, `dired-compress-file' is performed by
+  ;; default handler.
   (skip-unless (not (tramp--test-emacs29-p)))
 
   (let ((default-directory tramp-test-temporary-file-directory)
@@ -6955,7 +6956,8 @@ process sentinels.  They shall not disturb each other."
   (skip-unless (tramp--test-enabled))
   (skip-unless (tramp--test-sh-p))
   (skip-unless (not (tramp--test-crypt-p)))
-  ;; Starting with Emacs 29.1, `dired-compress-file' isn't magic anymore.
+  ;; Starting with Emacs 29.1, `dired-compress-file' is performed by
+  ;; default handler.
   (skip-unless (not (tramp--test-emacs29-p)))
 
   (let ((default-directory tramp-test-temporary-file-directory)