>From 4e60a56756958af4d8af095fab0dad661628ffcb Mon Sep 17 00:00:00 2001 From: Alexander Gramiak Date: Sat, 29 Dec 2018 11:54:24 -0600 Subject: [PATCH 2/5] 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 2bacb66d4a..af99e29e40 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -388,6 +388,10 @@ remapped to these, respectively. +++ *** New command 'dired-create-empty-file'. +--- +*** 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 9cd7998216..909d6f6666 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -996,6 +996,9 @@ dired-compress-file-suffixes ("\\.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) @@ -1020,6 +1023,7 @@ dired-compress-files-alist '(("\\.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'. @@ -1103,12 +1107,17 @@ dired-compress-file 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.20.1