changeset 106600:693859ba5ce8

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)
author Juri Linkov <juri@jurta.org>
date Wed, 16 Dec 2009 09:52:42 +0000
parents 65880e195610
children 5c030ace94f7
files lisp/ChangeLog lisp/dired-aux.el
diffstat 2 files changed, 28 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Dec 15 22:53:39 2009 +0000
+++ b/lisp/ChangeLog	Wed Dec 16 09:52:42 2009 +0000
@@ -1,3 +1,12 @@
+2009-12-16  Juri Linkov  <juri@jurta.org>
+
+	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)
+
 2009-12-15  Michael Albinus  <michael.albinus@gmx.de>
 
 	* net/tramp.el (tramp-echo-mark-marker-length): New defconst.
--- a/lisp/dired-aux.el	Tue Dec 15 22:53:39 2009 +0000
+++ b/lisp/dired-aux.el	Wed Dec 16 09:52:42 2009 +0000
@@ -60,21 +60,31 @@
 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)