unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Raoul Comninos <revcomninos@gmail.com>
Cc: 39024-done@debbugs.gnu.org
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	[thread overview]
Message-ID: <83lfqhc3st.fsf@gnu.org> (raw)
In-Reply-To: <CAHcEtGLpMy0q0AP+HRCHprUd6W2SAoVfeKjjrQbgBvei4tWmbw@mail.gmail.com> (message from Raoul Comninos on Wed, 8 Jan 2020 00:54:45 +0200)

> From: Raoul Comninos <revcomninos@gmail.com>
> 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
below.

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))
       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:
   (REGEXP NEW-SUFFIX PROGRAM)
@@ -1145,7 +1153,7 @@ dired-compress-file
            (condition-case nil
                (if (file-directory-p file)
                    (progn
-                     (setq suffix (cdr (assoc ":" dired-compress-file-suffixes)))
+                     (setq suffix (cdr (assoc "\000" dired-compress-file-suffixes)))
                      (when suffix
                        (let ((out-name (concat file (car suffix)))
                              (default-directory (file-name-directory file)))





  reply	other threads:[~2020-01-08 16:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-07 22:54 bug#39024: 28.0.50; Unable to compress or uncompress files in Emacs on Windows 10 Raoul Comninos
2020-01-08 16:26 ` Eli Zaretskii [this message]
     [not found]   ` <CAHcEtGKdOm=TYu_DX2jyzz69Yh-nra-6PpZV1xABStDmkDKQCQ@mail.gmail.com>
2020-01-08 20:08     ` Eli Zaretskii
     [not found]       ` <CAHcEtG+n-zc7VcX6urWcWbWVMZ2aoeU2+jNj3JiQhQ0Om=j6ag@mail.gmail.com>
2020-01-09  3:29         ` Eli Zaretskii
     [not found]           ` <CAHcEtGLe4UzHA9XiH7MXoUdMxYEsXsF9dzHcUQ14B6UTivMGPA@mail.gmail.com>
2020-01-09 13:49             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83lfqhc3st.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=39024-done@debbugs.gnu.org \
    --cc=revcomninos@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).