proceed))
;;;###autoload
-(defun dired-diff (file &optional switches)
- "Compare file at point with FILE using `diff'.
+(defun dired-diff (file &optional switches current)
+ "Compare CURRENT file with FILE using `diff'.
If called interactively, prompt for FILE.
If the mark is active in Transient Mark mode, use the file at the mark
as the default for FILE. (That's the mark set by \\[set-mark-command],
;; `M-n' candidates.
(file-backup-file-names current))
(dired-dwim-target-defaults (list current) target-dir))))
+ (when default (push (expand-file-name default) defaults))
(list
- (minibuffer-with-setup-hook
- (lambda ()
- (setq-local minibuffer-default-add-function nil)
- (setq minibuffer-default defaults))
- (read-file-name (format-prompt "Diff %s with" default current)
- target-dir default t))
+ (read-file-name (format-prompt "Diff %s with" defaults current)
+ target-dir defaults t)
(if current-prefix-arg
(read-string "Options for diff: "
(if (stringp diff-switches)
diff-switches
- (mapconcat #'identity diff-switches " "))))))
+ (mapconcat #'identity diff-switches " "))))
+ current))
dired-mode)
- (let ((current (dired-get-filename t)))
- (when (or (equal (expand-file-name file)
- (expand-file-name current))
- (and (file-directory-p file)
- (equal (expand-file-name current file)
- (expand-file-name current))))
- (error "Attempt to compare the file to itself"))
- (if (and (backup-file-name-p current)
- (equal file (file-name-sans-versions current)))
- (diff current file switches)
- (diff file current switches))))
+ (setq current (or current (dired-get-filename t)))
+ (diff file current switches))
;;;###autoload
(defun dired-backup-diff (&optional switches)