[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: M-= in Dired
Re: M-= in Dired
Sat, 15 Sep 2012 02:45:10 +0300
Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (x86_64-pc-linux-gnu)
> I think it's possible to do this in dired-diff without throwing away
> useful functionality of using as default a marked file or a file in
> adjacent windows (dwim-target). The top default value could be
> a backup file but remaining defaults could remain the same as before.
This patch keeps the new functionality of using the latest existing
backup file, and restores the original functionality of using the default
file with the mark on it and adding more defaults for dwim directories:
=== modified file 'lisp/dired-aux.el'
--- lisp/dired-aux.el 2012-09-13 23:42:39 +0000
+++ lisp/dired-aux.el 2012-09-14 23:45:05 +0000
@@ -62,17 +62,31 @@ (defun dired-diff (file &optional switch
which is the string of command switches for `diff'."
(let* ((current (dired-get-filename t))
- (oldf (file-newest-backup current))
- (dir (if oldf (file-name-directory oldf))))
- (list (read-file-name
- (format "Diff %s with%s: "
- (file-name-nondirectory current)
- (if oldf
- (concat " (default "
- (file-name-nondirectory oldf)
- dir oldf t)
+ ;; Get the latest existing backup file.
+ (oldf (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))
+ (dired-get-filename t t))))
+ (default-file (or file-at-mark
+ (and oldf (file-name-nondirectory oldf))))
+ ;; Use it as default if it's not the same as the current file.
+ (default (if (not (equal default-file current))
+ (if (not (equal (dired-dwim-target-directory)
+ (dired-dwim-target-defaults (list current)
+ (format "Diff %s with%s: " current
+ (if default (format " (default %s)" default) ""))
+ (if default
+ (delq nil (append (list default) defaults))
(read-string "Options for diff: "
(if (stringp diff-switches)
RE: M-= in Dired, Drew Adams, 2012/09/07
Re: M-= in Dired, Juri Linkov, 2012/09/09
- Re: M-= in Dired,
Juri Linkov <=