(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)))
;; 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
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
((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
(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
(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))
;; 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))
;; 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