* x-dnd.el (x-dnd-maybe-call-test-function):
[bpt/emacs.git] / lisp / dired-aux.el
index 0fcefe9..ffe02ca 100644 (file)
@@ -196,7 +196,7 @@ condition.  Two file items are considered to match if they are equal
 
 (defun dired-files-attributes (dir)
   "Return a list of all file names and attributes from DIR.
-List has a form of (file-name full-file-name (attribute-list))"
+List has a form of (file-name full-file-name (attribute-list))."
   (mapcar
    (lambda (file-name)
      (let ((full-file-name (expand-file-name file-name dir)))
@@ -488,7 +488,7 @@ to the end of the list of defaults just after the default value."
 
 ;; This is an extra function so that you can redefine it, e.g., to use gmhist.
 (defun dired-read-shell-command (prompt arg files)
-  "Read a dired shell command prompting with PROMPT (using read-shell-command).
+  "Read a dired shell command prompting with PROMPT (using `read-shell-command').
 ARG is the prefix arg and may be used to indicate in the prompt which
 FILES are affected."
   (minibuffer-with-setup-hook
@@ -551,9 +551,9 @@ This feature does not try to redisplay Dired buffers afterward, as
 there's no telling what files COMMAND may have changed.
 Type \\[dired-do-redisplay] to redisplay the marked files.
 
-When COMMAND runs, its working directory is the top-level directory of
-the Dired buffer, so output files usually are created there instead of
-in a subdir.
+When COMMAND runs, its working directory is the top-level directory
+of the Dired buffer, so output files usually are created there
+instead of in a subdir.
 
 In a noninteractive call (from Lisp code), you must specify
 the list of file names explicitly with the FILE-LIST argument, which
@@ -887,25 +887,33 @@ Binding variable `help-form' will help the user who types the help key."
          ((eq 'no action)
           nil)                         ; skip, and don't ask again
          (t;; no lasting effects from last time we asked - ask now
-          (let ((qprompt (concat qs-prompt
+          (let ((cursor-in-echo-area t)
+                (executing-kbd-macro executing-kbd-macro)
+                (qprompt (concat qs-prompt
                                  (if help-form
                                      (format " [Type yn!q or %s] "
                                              (key-description
                                               (char-to-string help-char)))
                                    " [Type y, n, q or !] ")))
-                result elt)
-            ;; Actually it looks nicer without cursor-in-echo-area - you can
-            ;; look at the dired buffer instead of at the prompt to decide.
-            (apply 'message qprompt qs-args)
-            (while (progn (setq char (set qs-var (read-key)))
-                           (not (setq elt (assoc char dired-query-alist))))
-              (message "Invalid key - type %c for help." help-char)
-              (ding)
-              (sit-for 1)
-              (apply 'message qprompt qs-args))
+                done result elt)
+            (while (not done)
+              (apply 'message qprompt qs-args)
+              (setq char (set qs-var (read-event)))
+              (if (numberp char)
+                  (cond ((and executing-kbd-macro (= char -1))
+                         ;; read-event returns -1 if we are in a kbd
+                         ;; macro and there are no more events in the
+                         ;; macro.  Attempt to get an event
+                         ;; interactively.
+                         (setq executing-kbd-macro nil))
+                        ((eq (key-binding (vector char)) 'keyboard-quit)
+                         (keyboard-quit))
+                        (t
+                         (setq done (setq elt (assoc char
+                                                     dired-query-alist)))))))
             ;; Display the question with the answer.
             (message "%s" (concat (apply 'format qprompt qs-args)
-                             (char-to-string char)))
+                                  (char-to-string char)))
             (memq (cdr elt) '(t y yes)))))))
 \f
 ;;;###autoload
@@ -1209,51 +1217,7 @@ Special value `always' suppresses confirmation."
             (or (eq recursive 'always)
                 (yes-or-no-p (format "Recursive copies of %s? " from))))
        ;; This is a directory.
-       (let ((mode (or (file-modes from) #o700))
-             (files
-              (condition-case err
-                  (directory-files from nil dired-re-no-dot)
-                (file-error
-                 (push (dired-make-relative from)
-                       dired-create-files-failures)
-                 (dired-log "Copying error for %s:\n%s\n" from err)
-                 (setq dirfailed t)
-                 nil))))
-         (if (eq recursive 'top) (setq recursive 'always)) ; Don't ask any more.
-         (unless dirfailed
-           (if (file-exists-p to)
-               (or top (dired-handle-overwrite to))
-             (condition-case err
-                 ;; We used to call set-file-modes here, but on some
-                 ;; Linux kernels, that returns an error on vfat
-                 ;; filesystems
-                 (let ((default-mode (default-file-modes)))
-                   (unwind-protect
-                       (progn
-                         (set-default-file-modes #o700)
-                         (make-directory to))
-                     (set-default-file-modes default-mode)))
-               (file-error
-                (push (dired-make-relative from)
-                      dired-create-files-failures)
-                (setq files nil)
-                (dired-log "Copying error for %s:\n%s\n" from err)))))
-         (dolist (file files)
-           (let ((thisfrom (expand-file-name file from))
-                 (thisto (expand-file-name file to)))
-             ;; Catch errors copying within a directory,
-             ;; and report them through the dired log mechanism
-             ;; just as our caller will do for the top level files.
-             (condition-case err
-                 (dired-copy-file-recursive
-                  thisfrom thisto
-                  ok-flag preserve-time nil recursive)
-               (file-error
-                (push (dired-make-relative thisfrom)
-                      dired-create-files-failures)
-                (dired-log "Copying error for %s:\n%s\n" thisfrom err)))))
-         (when (file-directory-p to)
-           (set-file-modes to mode)))
+       (copy-directory from to dired-copy-preserve-time)
       ;; Not a directory.
       (or top (dired-handle-overwrite to))
       (condition-case err
@@ -1287,8 +1251,7 @@ Special value `always' suppresses confirmation."
   (let ((expanded-from-dir (expand-file-name from-dir))
        (blist (buffer-list)))
     (while blist
-      (save-excursion
-       (set-buffer (car blist))
+      (with-current-buffer (car blist)
        (if (and buffer-file-name
                 (dired-in-this-tree buffer-file-name expanded-from-dir))
            (let ((modflag (buffer-modified-p))
@@ -1566,8 +1529,7 @@ Optional arg HOW-TO determiness how to treat the target.
     ;; non-dired buffer may want to profit from this function, e.g. vm-uudecode
     (if dired-dwim-target
        (let* ((other-buf (window-buffer (next-window)))
-              (other-dir (save-excursion
-                           (set-buffer other-buf)
+              (other-dir (with-current-buffer other-buf
                            (and (eq major-mode 'dired-mode)
                                 (dired-current-directory)))))
          (or other-dir this-dir))
@@ -1606,7 +1568,7 @@ Optional arg HOW-TO determiness how to treat the target.
 ;; symlinks.
 
 (defvar dired-copy-how-to-fn nil
-  "nil or a function used by `dired-do-copy' to determine target.
+  "Either nil or a function used by `dired-do-copy' to determine target.
 See HOW-TO argument for `dired-do-create-files'.")
 
 ;;;###autoload