From: Michael Albinus Date: Sat, 13 Nov 2021 14:14:02 +0000 (+0100) Subject: Remove Tramp's `dired-compress-file' handler, not needed anymore X-Git-Tag: emacs-29.0.90~2852^2~306 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=aa88845a170fef902fdd7d757b0f178ce41fe816;p=emacs.git 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. --- diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 7d81d45326f..92409db33ea 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -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")))))))) diff --git a/lisp/icomplete.el b/lisp/icomplete.el index f909a3b1771..8ead8a6217c 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -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 diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 374e5db5879..895543d6db9 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -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) diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el index 578f9fcf913..3e0d876dd9e 100644 --- a/lisp/net/tramp-archive.el +++ b/lisp/net/tramp-archive.el @@ -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) diff --git a/lisp/net/tramp-crypt.el b/lisp/net/tramp-crypt.el index f431f975633..42b67ac7a8e 100644 --- a/lisp/net/tramp-crypt.el +++ b/lisp/net/tramp-crypt.el @@ -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) diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index 11de71aa0d9..220ce63c0f7 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -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) diff --git a/lisp/net/tramp-rclone.el b/lisp/net/tramp-rclone.el index c997215a15b..28a1c01aa61 100644 --- a/lisp/net/tramp-rclone.el +++ b/lisp/net/tramp-rclone.el @@ -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) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 533ddcf66ea..c61025a86b2 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -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) diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index ac567dc0747..0b25164902e 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -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) diff --git a/lisp/net/tramp-sshfs.el b/lisp/net/tramp-sshfs.el index fc77d998aa6..a9d8dc933b3 100644 --- a/lisp/net/tramp-sshfs.el +++ b/lisp/net/tramp-sshfs.el @@ -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) diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el index 842990488ef..7cf0ea451d2 100644 --- a/lisp/net/tramp-sudoedit.el +++ b/lisp/net/tramp-sudoedit.el @@ -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) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index f4493608a46..876bbb2c545 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -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)) diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 397e707f136..52c6159dc12 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -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)