aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/dired-aux.el44
1 files changed, 31 insertions, 13 deletions
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 83fcf480b74..ff1f14d7a65 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -54,19 +54,23 @@ into this list; they also should call `dired-log' to log the errors.")
54 54
55;;;###autoload 55;;;###autoload
56(defun dired-diff (file &optional switches) 56(defun dired-diff (file &optional switches)
57 "Compare file at point with file FILE using `diff'. 57 "Compare file at point with FILE using `diff'.
58If called interactively, prompt for FILE. If the file at point 58If called interactively, prompt for FILE.
59has a backup file, use that as the default. If the file at point 59If the mark is active in Transient Mark mode, use the file at the mark
60is a backup file, use its original. If the mark is active 60as the default for FILE. (That's the mark set by \\[set-mark-command],
61in Transient Mark mode, use the file at the mark as the default. 61not by Dired's \\[dired-mark] command.)
62\(That's the mark set by \\[set-mark-command], not by Dired's 62If the file at point has a backup file, use that as the default FILE.
63\\[dired-mark] command.) 63If the file at point is a backup file, use its original, if that exists
64 64and can be found. Note that customizations of `backup-directory-alist'
65FILE is the first file given to `diff'. The file at point 65and `make-backup-file-name-function' change where this function searches
66is the second file given to `diff'. 66for the backup file, and affect its ability to find the original of a
67backup file.
68
69FILE is the first argument given to the `diff' function. The file at
70point is the second argument given to `diff'.
67 71
68With prefix arg, prompt for second argument SWITCHES, which is 72With prefix arg, prompt for second argument SWITCHES, which is
69the string of command switches for the third argument of `diff'." 73the string of command switches used as the third argument of `diff'."
70 (interactive 74 (interactive
71 (let* ((current (dired-get-filename t)) 75 (let* ((current (dired-get-filename t))
72 ;; Get the latest existing backup file or its original. 76 ;; Get the latest existing backup file or its original.
@@ -77,8 +81,20 @@ the string of command switches for the third argument of `diff'."
77 (file-at-mark (if (and transient-mark-mode mark-active) 81 (file-at-mark (if (and transient-mark-mode mark-active)
78 (save-excursion (goto-char (mark t)) 82 (save-excursion (goto-char (mark t))
79 (dired-get-filename t t)))) 83 (dired-get-filename t t))))
84 (separate-dir (and oldf
85 (not (equal (file-name-directory oldf)
86 (dired-current-directory)))))
80 (default-file (or file-at-mark 87 (default-file (or file-at-mark
81 (and oldf (file-name-nondirectory oldf)))) 88 ;; If the file with which to compare
89 ;; doesn't exist, or we cannot intuit it,
90 ;; we forget that name and don't show it
91 ;; as the default, as an indication to the
92 ;; user that she should type the file
93 ;; name.
94 (and (if (and oldf (file-readable-p oldf)) oldf)
95 (if separate-dir
96 oldf
97 (file-name-nondirectory oldf)))))
82 ;; Use it as default if it's not the same as the current file, 98 ;; Use it as default if it's not the same as the current file,
83 ;; and the target dir is current or there is a default file. 99 ;; and the target dir is current or there is a default file.
84 (default (if (and (not (equal default-file current)) 100 (default (if (and (not (equal default-file current))
@@ -87,7 +103,9 @@ the string of command switches for the third argument of `diff'."
87 default-file)) 103 default-file))
88 default-file)) 104 default-file))
89 (target-dir (if default 105 (target-dir (if default
90 (dired-current-directory) 106 (if separate-dir
107 (file-name-directory default)
108 (dired-current-directory))
91 (dired-dwim-target-directory))) 109 (dired-dwim-target-directory)))
92 (defaults (dired-dwim-target-defaults (list current) target-dir))) 110 (defaults (dired-dwim-target-defaults (list current) target-dir)))
93 (list 111 (list