Remove Tramp's `dired-compress-file' handler, not needed anymore

* 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.
This commit is contained in:
Michael Albinus 2021-11-13 15:14:02 +01:00
parent f7abc04c40
commit aa88845a17
13 changed files with 86 additions and 84 deletions

View 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"))))))))

View 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

View 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)

View 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)

View 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)

View 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)

View 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)

View 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))))
;; 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)))))))))))
(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)

View 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)

View 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)

View 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)

View 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))

View 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)