From c32cc62779ea31200df21c7c02c83bcb33ce7d21 Mon Sep 17 00:00:00 2001 From: Alexander Gramiak Date: Mon, 24 Jun 2019 15:56:32 +0200 Subject: [PATCH] Add Zstandard compression support for dired * lisp/dired-aux.el (dired-compress-file-suffixes): Add suffixes for zstd compressed tarballs and other files. (dired-compress-file): Treat options found in `dired-compress-file-suffixes' as arguments instead of part of the program name. --- etc/NEWS | 4 ++++ lisp/dired-aux.el | 21 +++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 8934dc10fb6..5e134c47e42 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -606,6 +606,10 @@ The default value is 'find-dired-sort-by-filename'. *** New sorting options for the variable 'find-ls-option'. +--- +*** Zstandard compression is now supported for 'dired-do-compress' and +'dired-do-compress-to'. + ** Change Logs and VC *** Recording ChangeLog entries doesn't require an actual file. diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 2705c0ad2a3..5e4ec4d1ecb 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -999,6 +999,9 @@ command with a prefix argument (the value does not matter)." ("\\.bz2\\'" "" "bunzip2") ("\\.xz\\'" "" "unxz") ("\\.zip\\'" "" "unzip -o -d %o %i") + ("\\.tar\\.zst\\'" "" "unzstd -c %i | tar -xf -") + ("\\.tzst\\'" "" "unzstd -c %i | tar -xf -") + ("\\.zst\\'" "" "unzstd --rm") ("\\.7z\\'" "" "7z x -aoa -o%o %i") ;; This item controls naming for compression. ("\\.tar\\'" ".tgz" nil) @@ -1023,6 +1026,7 @@ ARGS are command switches passed to PROGRAM.") '(("\\.tar\\.gz\\'" . "tar -cf - %i | gzip -c9 > %o") ("\\.tar\\.bz2\\'" . "tar -cf - %i | bzip2 -c9 > %o") ("\\.tar\\.xz\\'" . "tar -cf - %i | xz -c9 > %o") + ("\\.tar\\.zst\\'" . "tar -cf - %i | zstd -19 -o %o") ("\\.zip\\'" . "zip %o -r --filesync %i")) "Control the compression shell command for `dired-do-compress-to'. @@ -1108,12 +1112,17 @@ Return nil if no change in files." nil t) nil t))) ;; We found an uncompression rule. - (when (not - (dired-check-process - (concat "Uncompressing " file) - command - file)) - newname))) + (let ((match (string-match " " command)) + (msg (concat "Uncompressing " file))) + (unless (if match + (dired-check-process msg + (substring command 0 match) + (substring command (1+ match)) + file) + (dired-check-process msg + command + file)) + newname)))) (t ;; We don't recognize the file as compressed, so compress it. ;; Try gzip; if we don't have that, use compress. -- 2.39.5