]> code.delx.au - gnu-emacs/blobdiff - lisp/dired-aux.el
(MIPS2): Comment out define.
[gnu-emacs] / lisp / dired-aux.el
index 3b66c68598fe66183d42d038ddc2bc4b24fb76f0..e452bf26c61606826268af1f774f46c8dc96b7fc 100644 (file)
@@ -1,4 +1,4 @@
-;; dired-aux.el --- all of dired except what people usually use
+;;; dired-aux.el --- all of dired except what people usually use
 
 ;; Copyright (C) 1985, 1986, 1992 Free Software Foundation, Inc.
 
 
 ;;; Commentary:
 
+;; The parts of dired mode not normally used.  This is a space-saving hack
+;; to avoid having to load a large mode when all that's wanted are a few
+;; functions.
+
 ;; Rewritten in 1990/1991 to add tree features, file marking and
 ;; sorting by Sebastian Kremer <sk@thp.uni-koeln.de>.
 ;; Finished up by rms in 1992.
@@ -477,25 +481,31 @@ and use this command with a prefix argument (the value does not matter)."
   ;; Compress or uncompress FILE.
   ;; Return the name of the compressed or uncompressed file.
   ;; Rerurn nil if no change in files.
-  (let (handler (handlers file-name-handler-alist))
-    (while (and (consp handlers) (null handler))
-      (if (and (consp (car handlers))
-              (stringp (car (car handlers)))
-              (string-match (car (car handlers)) file))
-         (setq handler (cdr (car handlers))))
-      (setq handlers (cdr handlers)))
+  (let ((handler (find-file-name-handler file)))
     (cond (handler
           (funcall handler 'dired-compress-file file))
          ((file-symlink-p file)
           nil)
-         ((string-match "\\.Z$" file)
-          (if (dired-check-process (concat "Uncompressing " from-file)
-                                   "uncompress" from-file)
+         ((let (case-fold-search)
+            (string-match "\\.Z$" file))
+          (if (not (dired-check-process (concat "Uncompressing " file)
+                                        "uncompress" file))
               (substring file 0 -2)))
+         ((let (case-fold-search)
+            (string-match "\\.gz$" file))
+          (if (not (dired-check-process (concat "Uncompressing " file)
+                                        "gunzip" file))
+              (substring file 0 -3)))
          (t
-          (if (dired-check-process (concat "Compressing " from-file)
-                                   "compress" "-f" from-file)
-              (concat name ".Z"))))))
+          ;;; Try gzip; if we don't have that, use compress.
+          (condition-case nil
+              (if (not (dired-check-process (concat "Compressing " file)
+                                            "gzip" "-f" file))
+                  (concat file ".gz"))
+            (file-error
+             (if (not (dired-check-process (concat "Compressing " file)
+                                           "compress" "-f" file))
+                 (concat file ".Z"))))))))
 \f
 (defun dired-mark-confirm (op-symbol arg)
   ;; Request confirmation from the user that the operation described
@@ -504,9 +514,11 @@ and use this command with a prefix argument (the value does not matter)."
   ;; pop-up unless OP-SYMBOL is a member of `dired-no-confirm'.
   ;; The files used are determined by ARG (as in dired-get-marked-files).
   (or (memq op-symbol dired-no-confirm)
-      (let ((files (dired-get-marked-files t arg)))
+      (let ((files (dired-get-marked-files t arg))
+           (string (if (eq op-symbol 'compress) "Compress or uncompress"
+                     (capitalize (symbol-name op-symbol)))))
        (dired-mark-pop-up nil op-symbol files (function y-or-n-p)
-                          (concat (capitalize (symbol-name op-symbol)) " "
+                          (concat string " "
                                   (dired-mark-prompt arg files) "? ")))))
 
 (defun dired-map-over-marks-check (fun arg op-symbol &optional show-progress)
@@ -528,15 +540,16 @@ and use this command with a prefix argument (the value does not matter)."
              (dired-map-over-marks (funcall fun) arg show-progress))
             (total (length total-list))
             (failures (delq nil total-list))
-            (count (length failures)))
+            (count (length failures))
+            (string (if (eq op-symbol 'compress) "Compress or uncompress"
+                      (capitalize (symbol-name op-symbol)))))
        (if (not failures)
            (message "%s: %d file%s."
-                    (capitalize (symbol-name op-symbol))
-                    total (dired-plural-s total))
+                    string total (dired-plural-s total))
          ;; end this bunch of errors:
          (dired-log-summary
           (format "Failed to %s %d of %d file%s"
-                  (symbol-name op-symbol) count total (dired-plural-s total))
+                  (downcase string) count total (dired-plural-s total))
           failures)))))
 
 (defvar dired-query-alist
@@ -1299,8 +1312,7 @@ Type SPC or `y' to %s one match, DEL or `n' to skip to next,
          (if whole-path nil current-prefix-arg))
         (regexp
          (dired-read-regexp
-          (concat (if whole-path "Path " "") operation " from (regexp): ")
-          dired-flagging-regexp))
+          (concat (if whole-path "Path " "") operation " from (regexp): ")))
         (newname
          (read-string
           (concat (if whole-path "Path " "") operation " " regexp " to: "))))