Subject: bug#4953: 23.1.50; Dired does not deal well with xz-compressed files

From: Sven Joachim <[email-masked]>
Date: Sat, 21 Nov 2009 22:56:47 +0100

tags 4953 + patch
thanks

On 2009-11-19 08:55 +0100, Sven Joachim wrote:

> On 2009-11-19 08:42 +0100, Glenn Morris wrote:
>
>> Sven Joachim wrote:
>>
>>> - dired-do-shell-command does not offer anything for file.tar.xz
>>
>> I don't know what this means. M-x dired-do-shell-command for
>> foo.tar.gz doesn't seem to do anything special.
>
> You need to load dired-x first (Info "(dired-x) Shell Command Guessing").

Here is a patch that adds support for xz-compressed files to
dired-guess-shell-alist-default, emulating the case of bzip2-compressed
files:

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index 4da19f6..dce8685 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -1017,6 +1017,16 @@ dired."
 	 ;; Optional decompression.
 	 "bunzip2")
 
+   ;; xz'ed archives
+   (list "\\.t\\(ar\\.\\)?xz$"
+	 "unxz -c * | tar xvf -"
+	 ;; Extract files into a separate subdirectory
+	 '(concat "mkdir " (file-name-sans-extension file)
+		  "; unxz -c * | tar -C "
+		  (file-name-sans-extension file) " -xvf -")
+	 ;; Optional decompression.
+	 "unxz")
+
    '("\\.shar\\.Z$" "zcat * | unshar")
    '("\\.shar\\.g?z$" "gunzip -qc * | unshar")
 
@@ -1098,6 +1108,7 @@ dired."
    (list "\\.g?z$" '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q")))
    (list "\\.dz$" "dictunzip")
    (list "\\.bz2$" "bunzip2")
+   (list "\\.xz$" "unxz")
    (list "\\.Z$" "uncompress"
 	 ;; Optional conversion to gzip format.
 	 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
--8<---------------cut here---------------end--------------->8---

Suggested Changelog entry:

2009-11-21  Sven Joachim  <[email-masked]>

	* dired-x.el (dired-guess-shell-alist-default): Support xz format.

Cheers,
       Sven