summaryrefslogtreecommitdiff
path: root/lisp/dired-aux.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@jurta.org>2009-12-16 09:52:42 +0000
committerJuri Linkov <juri@jurta.org>2009-12-16 09:52:42 +0000
commit72b57560300f433795ef02115b7085e5699cea03 (patch)
treef4d88c9632d65d9c69d06cf011e58f2a79069c55 /lisp/dired-aux.el
parent7eeb56addbec7cd5dd9226b5a7f4710f7e8c39b1 (diff)
downloademacs-72b57560300f433795ef02115b7085e5699cea03.tar.gz
Revert to old 23.1 logic of using the file at the mark as default.
* dired-aux.el (dired-diff): Use the file at the mark as default if it's not the same as the current file, and the target dir is the current dir or the mark is active. Add the current file as the arg of `dired-dwim-target-defaults'. Use the default file in the prompt. (Bug#5225)
Diffstat (limited to 'lisp/dired-aux.el')
-rw-r--r--lisp/dired-aux.el28
1 files changed, 19 insertions, 9 deletions
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 4976d2cd683..d3f5de72c7f 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -60,21 +60,31 @@ With prefix arg, prompt for second argument SWITCHES,
which is options for `diff'."
(interactive
(let* ((current (dired-get-filename t))
- (target-dir (dired-dwim-target-directory))
- (marked (and (mark t) (save-excursion
- (goto-char (mark t))
- (dired-get-filename nil t))))
- (defaults
- (append (dired-dwim-target-defaults nil target-dir)
- ;; Additional file with the mark.
- (and marked (list marked)))))
+ ;; Get the file at the mark.
+ (file-at-mark (if (mark t)
+ (save-excursion (goto-char (mark t))
+ (dired-get-filename t t))))
+ ;; Use it as default if it's not the same as the current file,
+ ;; and the target dir is the current dir or the mark is active.
+ (default (if (and (not (equal file-at-mark current))
+ (or (equal (dired-dwim-target-directory)
+ (dired-current-directory))
+ mark-active))
+ file-at-mark))
+ (target-dir (if default
+ (dired-current-directory)
+ (dired-dwim-target-directory)))
+ (defaults (dired-dwim-target-defaults (list current) target-dir)))
(require 'diff)
(list
(minibuffer-with-setup-hook
(lambda ()
(set (make-local-variable 'minibuffer-default-add-function) nil)
(setq minibuffer-default defaults))
- (read-file-name (format "Diff %s with: " current) target-dir nil t))
+ (read-file-name
+ (format "Diff %s with%s: " current
+ (if default (format " (default %s)" default) ""))
+ target-dir default t))
(if current-prefix-arg
(read-string "Options for diff: "
(if (stringp diff-switches)