aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/dired-aux.el51
1 files changed, 20 insertions, 31 deletions
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 049d200f590..e28106d9865 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -330,14 +330,13 @@ only in the active region if `dired-mark-region' is non-nil."
330 (interactive 330 (interactive
331 (list 331 (list
332 (let* ((target-dir (dired-dwim-target-directory)) 332 (let* ((target-dir (dired-dwim-target-directory))
333 (defaults (dired-dwim-target-defaults nil target-dir))) 333 (defaults (dired-dwim-target-defaults nil target-dir)))
334 (minibuffer-with-setup-hook 334 (minibuffer-with-setup-hook
335 (lambda () 335 (lambda ()
336 (setq-local minibuffer-default-add-function nil) 336 (setq-local minibuffer-default-add-function nil))
337 (setq minibuffer-default defaults))
338 (read-directory-name (format "Compare %s with: " 337 (read-directory-name (format "Compare %s with: "
339 (dired-current-directory)) 338 (dired-current-directory))
340 target-dir target-dir t))) 339 target-dir defaults t)))
341 (read-from-minibuffer "Mark if (lisp expr or RET): " nil nil t nil "nil")) 340 (read-from-minibuffer "Mark if (lisp expr or RET): " nil nil t nil "nil"))
342 dired-mode) 341 dired-mode)
343 (let* ((dir1 (dired-current-directory)) 342 (let* ((dir1 (dired-current-directory))
@@ -2668,17 +2667,12 @@ Optional arg HOW-TO determines how to treat the target.
2668 (dired-one-file ; fluid variable inside dired-create-files 2667 (dired-one-file ; fluid variable inside dired-create-files
2669 (and (consp fn-list) (null (cdr fn-list)) (car fn-list))) 2668 (and (consp fn-list) (null (cdr fn-list)) (car fn-list)))
2670 (target-dir (dired-dwim-target-directory)) 2669 (target-dir (dired-dwim-target-directory))
2671 (default (and dired-one-file
2672 (not dired-dwim-target) ; Bug#25609
2673 (expand-file-name (file-name-nondirectory
2674 (car fn-list))
2675 target-dir)))
2676 (defaults (dired-dwim-target-defaults fn-list target-dir)) 2670 (defaults (dired-dwim-target-defaults fn-list target-dir))
2677 (target (expand-file-name ; fluid variable inside dired-create-files 2671 (target (expand-file-name ; fluid variable inside dired-create-files
2678 (minibuffer-with-setup-hook 2672 (minibuffer-with-setup-hook
2679 (lambda () 2673 (lambda ()
2680 (setq-local minibuffer-default-add-function nil) 2674 ;; Don't run `read-file-name--defaults'
2681 (setq minibuffer-default defaults)) 2675 (setq-local minibuffer-default-add-function nil))
2682 (dired-mark-read-file-name 2676 (dired-mark-read-file-name
2683 (format "%s %%s %s: " 2677 (format "%s %%s %s: "
2684 (if dired-one-file op1 operation) 2678 (if dired-one-file op1 operation)
@@ -2688,7 +2682,7 @@ Optional arg HOW-TO determines how to treat the target.
2688 ;; other operations copy (etc) to the 2682 ;; other operations copy (etc) to the
2689 ;; prompted file name. 2683 ;; prompted file name.
2690 "from" "to")) 2684 "from" "to"))
2691 target-dir op-symbol arg rfn-list default)))) 2685 target-dir op-symbol arg rfn-list defaults))))
2692 (into-dir 2686 (into-dir
2693 (progn 2687 (progn
2694 (when 2688 (when
@@ -2813,28 +2807,26 @@ Optional arg HOW-TO determines how to treat the target.
2813 this-dir))) 2807 this-dir)))
2814 2808
2815(defun dired-dwim-target-defaults (fn-list target-dir) 2809(defun dired-dwim-target-defaults (fn-list target-dir)
2816 ;; Return a list of default values for file-reading functions in Dired. 2810 "Return a list of default values for file-reading functions in Dired.
2817 ;; This list may contain directories from Dired buffers in other windows. 2811
2818 ;; `fn-list' is a list of file names used to build a list of defaults. 2812This list may contain directories from Dired buffers in other windows.
2819 ;; When nil or more than one element, a list of defaults will 2813FN-LIST is a list of file names used to build a list of defaults.
2820 ;; contain only directory names. `target-dir' is a directory name 2814When nil or more than one element, a list of defaults will
2821 ;; to exclude from the returned list, for the case when this 2815contain only directory names.
2822 ;; directory name is already presented in initial input. 2816
2823 ;; For Dired operations that support `dired-dwim-target', 2817TARGET-DIR should be the initial input in the minibuffer for the
2824 ;; the argument `target-dir' should have the value returned 2818file-reading function. For Dired operations that support
2825 ;; from `dired-dwim-target-directory'. 2819`dired-dwim-target', TARGET-DIR should have the value returned from
2820`dired-dwim-target-directory'."
2826 (let ((dired-one-file 2821 (let ((dired-one-file
2827 (and (consp fn-list) (null (cdr fn-list)) (car fn-list))) 2822 (and (consp fn-list) (null (cdr fn-list)) (car fn-list)))
2828 (current-dir (and (eq major-mode 'dired-mode) 2823 (current-dir (and (eq major-mode 'dired-mode)
2829 (dired-current-directory))) 2824 (dired-current-directory)))
2830 ;; Get a list of directories of visible buffers in dired-mode. 2825 ;; Get a list of directories of visible buffers in dired-mode.
2831 (dired-dirs (dired-dwim-target-directories))) 2826 (dired-dirs (dired-dwim-target-directories)))
2832 ;; Force the current dir to be the first in the list. 2827 ;; Force TARGET-DIR then CURRENT-DIR to be first in the list.
2833 (setq dired-dirs 2828 (setq dired-dirs
2834 (delete-dups (delq nil (cons current-dir dired-dirs)))) 2829 (delete-dups (delq nil (cons target-dir (cons current-dir dired-dirs)))))
2835 ;; Remove the target dir (if specified) or the current dir from
2836 ;; default values, because it should be already in initial input.
2837 (setq dired-dirs (delete (or target-dir current-dir) dired-dirs))
2838 ;; Return a list of default values. 2830 ;; Return a list of default values.
2839 (if dired-one-file 2831 (if dired-one-file
2840 ;; For one file operation, provide a list that contains 2832 ;; For one file operation, provide a list that contains
@@ -2847,10 +2839,7 @@ Optional arg HOW-TO determines how to treat the target.
2847 (mapcar (lambda (dir) 2839 (mapcar (lambda (dir)
2848 (expand-file-name 2840 (expand-file-name
2849 (file-name-nondirectory (car fn-list)) dir)) 2841 (file-name-nondirectory (car fn-list)) dir))
2850 (reverse dired-dirs)) 2842 (reverse dired-dirs)))
2851 (list (expand-file-name
2852 (file-name-nondirectory (car fn-list))
2853 (or target-dir current-dir))))
2854 ;; For multi-file operation, return only a list of other directories. 2843 ;; For multi-file operation, return only a list of other directories.
2855 dired-dirs))) 2844 dired-dirs)))
2856 2845