summaryrefslogtreecommitdiff
path: root/lisp/dired-aux.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@jurta.org>2013-02-28 23:51:11 +0200
committerJuri Linkov <juri@jurta.org>2013-02-28 23:51:11 +0200
commit9d232fc451d9abc3e3ee3eead61176067470b24e (patch)
tree062a0376da0e020289cd60bc86411589c9837c86 /lisp/dired-aux.el
parent779451da533b042d2c84132e6157f49b38ede475 (diff)
downloademacs-9d232fc451d9abc3e3ee3eead61176067470b24e.tar.gz
* lisp/dired-aux.el (dired-diff): If file at point is a backup file,
use its original as the default value, and reverse the order of arguments to the `diff' call. Doc fix. Fixes: debbugs:13772
Diffstat (limited to 'lisp/dired-aux.el')
-rw-r--r--lisp/dired-aux.el14
1 files changed, 10 insertions, 4 deletions
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 13443419bd7..f6ff32b0b01 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -55,7 +55,8 @@ into this list; they also should call `dired-log' to log the errors.")
(defun dired-diff (file &optional switches)
"Compare file at point with file FILE using `diff'.
If called interactively, prompt for FILE. If the file at point
-has a backup file, use that as the default. If the mark is active
+has a backup file, use that as the default. If the file at point
+is a backup file, use its original. If the mark is active
in Transient Mark mode, use the file at the mark as the default.
\(That's the mark set by \\[set-mark-command], not by Dired's
\\[dired-mark] command.)
@@ -67,8 +68,10 @@ With prefix arg, prompt for second argument SWITCHES, which is
the string of command switches for the third argument of `diff'."
(interactive
(let* ((current (dired-get-filename t))
- ;; Get the latest existing backup file.
- (oldf (diff-latest-backup-file current))
+ ;; Get the latest existing backup file or its original.
+ (oldf (if (backup-file-name-p current)
+ (file-name-sans-versions current)
+ (diff-latest-backup-file current)))
;; Get the file at the mark.
(file-at-mark (if (and transient-mark-mode mark-active)
(save-excursion (goto-char (mark t))
@@ -107,7 +110,10 @@ the string of command switches for the third argument of `diff'."
(equal (expand-file-name current file)
(expand-file-name current))))
(error "Attempt to compare the file to itself"))
- (diff file current switches)))
+ (if (and (backup-file-name-p current)
+ (equal file (file-name-sans-versions current)))
+ (diff current file switches)
+ (diff file current switches))))
;;;###autoload
(defun dired-backup-diff (&optional switches)