[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#39024: 28.0.50; Unable to compress or uncompress files in Emacs on W

From: Eli Zaretskii
Subject: bug#39024: 28.0.50; Unable to compress or uncompress files in Emacs on Windows 10
Date: Wed, 08 Jan 2020 18:26:42 +0200

> From: Raoul Comninos <address@hidden>
> Date: Wed, 8 Jan 2020 00:54:45 +0200
> When I try to compress a file in Dired in Emacs on Windows 10 I get the 
> following error message:
> ls-lisp-insert-directory: Reading directory: Directory doesn't exist or is 
> inaccessible, c.tar.gz
> If I try in Emacs -Q I get a different error message:
> /usr/bin/bash: c.tar.gz/: Is a directory
> tar: Removing leading \c:/' from member names`

Thanks.  Compressing directories in Dired on Windows was botched ever
since it was introduced, and on platforms other than Windows it could
fail as well, for the same reasons, in some rare cases.

I've now fixed it for the upcoming Emacs 27.1.  In case you want to
patch your Emacs without waiting for the next release, the patch is

And with that, I'm closing the bug report.

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 59d389d..0069c17 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -992,7 +992,14 @@ dired-compress
          (ignore-errors (dired-remove-entry new-file))
          (goto-char start)
          ;; Now replace the current line with an entry for NEW-FILE.
-         (dired-update-file-line new-file) nil)
+         ;; But don't remove the current line if either FROM-FILE or
+         ;; NEW-FILE is a directory, because compressing/uncompressing
+          ;; directories doesn't remove the original.
+          (if (or (file-directory-p from-file)
+                  (file-directory-p new-file))
+              (dired-add-entry new-file nil t)
+            (dired-update-file-line new-file))
+          nil)
       (dired-log (concat "Failed to (un)compress " from-file))
@@ -1020,8 +1027,9 @@ dired-compress-file-suffixes
     ("\\.7z\\'" "" "7z x -aoa -o%o %i")
     ;; This item controls naming for compression.
     ("\\.tar\\'" ".tgz" nil)
-    ;; This item controls the compression of directories
-    (":" ".tar.gz" "tar -cf - %i | gzip -c9 > %o"))
+    ;; This item controls the compression of directories.  Its REGEXP
+    ;; element should never match any valid file name.
+    ("\000" ".tar.gz" "tar -cf - %i | gzip -c9 > %o"))
   "Control changes in file name suffixes for compression and uncompression.
 Each element specifies one transformation rule, and has the form:
@@ -1145,7 +1153,7 @@ dired-compress-file
            (condition-case nil
                (if (file-directory-p file)
-                     (setq suffix (cdr (assoc ":" 
+                     (setq suffix (cdr (assoc "\000" 
                      (when suffix
                        (let ((out-name (concat file (car suffix)))
                              (default-directory (file-name-directory file)))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]