aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleh Krehel2015-10-16 16:44:20 +0200
committerOleh Krehel2015-10-20 10:50:33 +0200
commitcfc34c1b3e99fac8c356f7b72df5ae4a36356313 (patch)
tree28bb0373a6ac96296c0ea1aa8750cc8990f21a66
parent10df0310cb8f43818eace6288cadaae62bd82eb6 (diff)
downloademacs-cfc34c1b3e99fac8c356f7b72df5ae4a36356313.tar.gz
emacs-cfc34c1b3e99fac8c356f7b72df5ae4a36356313.zip
Update the way directories are compressed
* lisp/dired-aux.el (dired-compress-file-suffixes): Update the recipe for *.tar.gz decompression to use a pipe. Add an entry for the default directory compression (to *.tar.g). (dired-compress-file): Update. See https://lists.gnu.org/archive/html/emacs-devel/2015-10/msg00949.html.
-rw-r--r--lisp/dired-aux.el59
1 files changed, 33 insertions, 26 deletions
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 8c575c6b12e..98a974a8223 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -880,7 +880,7 @@ command with a prefix argument (the value does not matter)."
880 from-file))) 880 from-file)))
881 881
882(defvar dired-compress-file-suffixes 882(defvar dired-compress-file-suffixes
883 '(("\\.tar\\.gz\\'" "" "tar -zxvf %i") 883 '(("\\.tar\\.gz\\'" "" "gzip -dc %i | tar -xv")
884 ("\\.gz\\'" "" "gunzip") 884 ("\\.gz\\'" "" "gunzip")
885 ("\\.tgz\\'" ".tar" "gunzip") 885 ("\\.tgz\\'" ".tar" "gunzip")
886 ("\\.Z\\'" "" "uncompress") 886 ("\\.Z\\'" "" "uncompress")
@@ -893,7 +893,9 @@ command with a prefix argument (the value does not matter)."
893 ("\\.xz\\'" "" "unxz") 893 ("\\.xz\\'" "" "unxz")
894 ("\\.zip\\'" "" "unzip -o -d %o %i") 894 ("\\.zip\\'" "" "unzip -o -d %o %i")
895 ;; This item controls naming for compression. 895 ;; This item controls naming for compression.
896 ("\\.tar\\'" ".tgz" nil)) 896 ("\\.tar\\'" ".tgz" nil)
897 ;; This item controls the compression of directories
898 (":" ".tar.gz" "tar -c %i | gzip -c9 > %o"))
897 "Control changes in file name suffixes for compression and uncompression. 899 "Control changes in file name suffixes for compression and uncompression.
898Each element specifies one transformation rule, and has the form: 900Each element specifies one transformation rule, and has the form:
899 (REGEXP NEW-SUFFIX PROGRAM) 901 (REGEXP NEW-SUFFIX PROGRAM)
@@ -952,31 +954,36 @@ Return nil if no change in files."
952 ;; We don't recognize the file as compressed, so compress it. 954 ;; We don't recognize the file as compressed, so compress it.
953 ;; Try gzip; if we don't have that, use compress. 955 ;; Try gzip; if we don't have that, use compress.
954 (condition-case nil 956 (condition-case nil
955 (let ((out-name (concat file (if (file-directory-p file) 957 (if (file-directory-p file)
956 ".tar.gz" 958 (progn
957 ".gz")))) 959 (setq suffix (cdr (assoc ":" dired-compress-file-suffixes)))
958 (and (or (not (file-exists-p out-name)) 960 (when suffix
959 (y-or-n-p 961 (let ((out-name (concat file (car suffix)))
960 (format "File %s already exists. Really compress? " 962 (default-directory (file-name-directory file)))
961 out-name))) 963 (dired-shell-command
962 (not 964 (replace-regexp-in-string
963 (if (file-directory-p file) 965 "%o" out-name
964 (let ((default-directory (file-name-directory file))) 966 (replace-regexp-in-string
965 (dired-check-process 967 "%i" (file-name-nondirectory file)
966 (concat "Compressing " file) 968 (cadr suffix))))
967 "tar" "-czf" 969 out-name)))
968 out-name (file-name-nondirectory file))) 970 (let ((out-name (concat file ".gz")))
971 (and (or (not (file-exists-p out-name))
972 (y-or-n-p
973 (format "File %s already exists. Really compress? "
974 out-name)))
975 (not
969 (dired-check-process (concat "Compressing " file) 976 (dired-check-process (concat "Compressing " file)
970 "gzip" "-f" file))) 977 "gzip" "-f" file))
971 (or (file-exists-p out-name) 978 (or (file-exists-p out-name)
972 (setq out-name (concat file ".z"))) 979 (setq out-name (concat file ".z")))
973 ;; Rename the compressed file to NEWNAME 980 ;; Rename the compressed file to NEWNAME
974 ;; if it hasn't got that name already. 981 ;; if it hasn't got that name already.
975 (if (and newname (not (equal newname out-name))) 982 (if (and newname (not (equal newname out-name)))
976 (progn 983 (progn
977 (rename-file out-name newname t) 984 (rename-file out-name newname t)
978 newname) 985 newname)
979 out-name))) 986 out-name))))
980 (file-error 987 (file-error
981 (if (not (dired-check-process (concat "Compressing " file) 988 (if (not (dired-check-process (concat "Compressing " file)
982 "compress" "-f" file)) 989 "compress" "-f" file))