-;; 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.
;; 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))
- (save-match-data
- (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 " file)
- "uncompress" 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 " file)
- "compress" "-f" 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
;; 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)
(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
(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: "))))