diff lisp/dired-aux.el @ 71928:87bfa39ee279

* dired-aux.el (dired-compress-file): Confirm again if gzipped file already exists.
author Chong Yidong <cyd@stupidchicken.com>
date Mon, 17 Jul 2006 04:00:54 +0000
parents fda2aa003809
children 954bc7af1cb8 8a8e69664178
line wrap: on
line diff
--- a/lisp/dired-aux.el	Sun Jul 16 23:30:58 2006 +0000
+++ b/lisp/dired-aux.el	Mon Jul 17 04:00:54 2006 +0000
@@ -745,19 +745,22 @@
 	   ;;; We don't recognize the file as compressed, so compress it.
 	   ;;; Try gzip; if we don't have that, use compress.
 	   (condition-case nil
-	       (if (not (dired-check-process (concat "Compressing " file)
-					     "gzip" "-f" file))
-		   (let ((out-name
-			  (if (file-exists-p (concat file ".gz"))
-			      (concat file ".gz")
-			    (concat file ".z"))))
-		     ;; Rename the compressed file to NEWNAME
-		     ;; if it hasn't got that name already.
-		     (if (and newname (not (equal newname out-name)))
-			 (progn
-			   (rename-file out-name newname t)
-			   newname)
-		       out-name)))
+	       (let ((out-name (concat file ".gz")))
+		 (and (or (not (file-exists-p out-name))
+			  (y-or-n-p
+			   (format "File %s already exists.  Really compress? "
+				   out-name)))
+		      (not (dired-check-process (concat "Compressing " file)
+						"gzip" "-f" file))
+		      (or (file-exists-p out-name)
+			  (setq out-name (concat file ".z")))
+		      ;; Rename the compressed file to NEWNAME
+		      ;; if it hasn't got that name already.
+		      (if (and newname (not (equal newname out-name)))
+			  (progn
+			    (rename-file out-name newname t)
+			    newname)
+			out-name)))
 	     (file-error
 	      (if (not (dired-check-process (concat "Compressing " file)
 					    "compress" "-f" file))