]> code.delx.au - gnu-emacs/blobdiff - lisp/dired-aux.el
*** empty log message ***
[gnu-emacs] / lisp / dired-aux.el
index 0dbe65007a82bd40658126594afddc05550af54e..4a2d8932457d73ee5816e7d751090608efe88140 100644 (file)
@@ -1,6 +1,6 @@
 ;;; dired-aux.el --- less commonly used parts of dired  -*-byte-compile-dynamic: t;-*-
 
-;; Copyright (C) 1985, 1986, 1992, 1994, 1998 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1986, 1992, 1994, 1998, 2000 Free Software Foundation, Inc.
 
 ;; Author: Sebastian Kremer <sk@thp.uni-koeln.de>.
 ;; Maintainer: FSF
@@ -1232,7 +1232,25 @@ ESC or `q' to not overwrite any of the remaining files,
                    (concat (if dired-one-file op1 operation) " %s to: ")
                    (dired-dwim-target-directory)
                    op-symbol arg rfn-list)))
-        (into-dir (cond ((null how-to) (file-directory-p target))
+        (into-dir (cond ((null how-to)
+                         ;; Allow DOS/Windows users to change the letter
+                         ;; case of a directory.  If we don't test these
+                         ;; conditions up front, file-directory-p below
+                         ;; will return t because the filesystem is
+                         ;; case-insensitive, and Emacs will try to move
+                         ;; foo -> foo/foo, which fails.
+                         (if (and (memq system-type '(ms-dos windows-nt))
+                                  (eq op-symbol 'move)
+                                  dired-one-file
+                                  (string= (downcase
+                                            (expand-file-name (car fn-list)))
+                                           (downcase
+                                            (expand-file-name target)))
+                                  (not (string=
+                                        (file-name-nondirectory (car fn-list))
+                                        (file-name-nondirectory target))))
+                             nil
+                           (file-directory-p target)))
                         ((eq how-to t) nil)
                         (t (funcall how-to target)))))
     (if (and (consp into-dir) (functionp (car into-dir)))
@@ -1320,11 +1338,11 @@ When operating on multiple or marked files, you specify a directory,
 and new copies of these files are made in that directory
 with the same names that the files currently have."
   (interactive "P")
-n  (let ((dired-recursive-copies dired-recursive-copies))
+  (let ((dired-recursive-copies dired-recursive-copies))
     (dired-do-create-files 'copy (function dired-copy-file)
-                            (if dired-copy-preserve-time "Copy [-p]" "Copy")
-                            arg dired-keep-marker-copy
-                            nil dired-copy-how-to-fn)))
+                          (if dired-copy-preserve-time "Copy [-p]" "Copy")
+                          arg dired-keep-marker-copy
+                          nil dired-copy-how-to-fn)))
 
 ;;;###autoload
 (defun dired-do-symlink (&optional arg)
@@ -1960,7 +1978,7 @@ To continue searching for next match, use command \\[tags-loop-continue]."
   (tags-search regexp '(dired-get-marked-files)))
 
 ;;;###autoload
-(defun dired-do-query-replace (from to &optional delimited)
+(defun dired-do-query-replace-regexp (from to &optional delimited)
   "Do `query-replace-regexp' of FROM with TO, on all marked files.
 Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
 If you exit (\\[keyboard-quit] or ESC), you can resume the query replace
@@ -1969,6 +1987,19 @@ with the command \\[tags-loop-continue]."
    "sQuery replace in marked files (regexp): \nsQuery replace %s by: \nP")
   (tags-query-replace from to delimited '(dired-get-marked-files)))
 \f
+;;;###autoload
+(defun dired-show-file-type (file &optional deref-symlinks)
+  "Print the type of FILE, according to the `file' command.
+If FILE is a symbolic link and the optional argument DEREF-SYMLINKS is
+true then the type of the file linked to by FILE is printed instead." 
+  (interactive (list (dired-get-filename t) current-prefix-arg))
+  (with-temp-buffer 
+    (if deref-symlinks
+       (call-process "file" nil t t "-L" file)
+      (call-process "file" nil t t file))
+    (when (bolp)
+      (backward-delete-char 1))
+    (message (buffer-string))))
 
 (provide 'dired-aux)