Function: dired-dwim-target-defaults
dired-dwim-target-defaults is a byte-compiled function defined in
dired-aux.el.gz.
Signature
(dired-dwim-target-defaults FN-LIST TARGET-DIR)
Documentation
Return a list of default values for file-reading functions in Dired.
This list may contain directories from Dired buffers in other windows. FN-LIST is a list of file names used to build a list of defaults. When nil or more than one element, a list of defaults will contain only directory names.
TARGET-DIR should be the initial input in the minibuffer for the
file-reading function. For Dired operations that support
dired-dwim-target, TARGET-DIR should have the value returned from
dired-dwim-target-directory.
Source Code
;; Defined in /usr/src/emacs/lisp/dired-aux.el.gz
(defun dired-dwim-target-defaults (fn-list target-dir)
"Return a list of default values for file-reading functions in Dired.
This list may contain directories from Dired buffers in other windows.
FN-LIST is a list of file names used to build a list of defaults.
When nil or more than one element, a list of defaults will
contain only directory names.
TARGET-DIR should be the initial input in the minibuffer for the
file-reading function. For Dired operations that support
`dired-dwim-target', TARGET-DIR should have the value returned from
`dired-dwim-target-directory'."
(let ((dired-one-file
(and (consp fn-list) (null (cdr fn-list)) (car fn-list)))
(current-dir (and (eq major-mode 'dired-mode)
(dired-current-directory)))
;; Get a list of directories of visible buffers in dired-mode.
(dired-dirs (dired-dwim-target-directories)))
;; Force TARGET-DIR then CURRENT-DIR to be first in the list.
(setq dired-dirs
(delete-dups (delq nil (cons target-dir (cons current-dir dired-dirs)))))
;; Return a list of default values.
(if dired-one-file
;; For one file operation, provide a list that contains
;; other directories, other directories with the appended filename
;; and the current directory with the appended filename, e.g.
;; 1. /TARGET-DIR/
;; 2. /TARGET-DIR/FILENAME
;; 3. /CURRENT-DIR/FILENAME
(append dired-dirs
(mapcar (lambda (dir)
(expand-file-name
(file-name-nondirectory (car fn-list)) dir))
(reverse dired-dirs)))
;; For multi-file operation, return only a list of other directories.
dired-dirs)))