]> git.eshelyaron.com Git - emacs.git/commitdiff
Extend the default value in dired-diff to all the backup files
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 24 Aug 2020 17:15:27 +0000 (19:15 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 24 Aug 2020 17:15:27 +0000 (19:15 +0200)
* lisp/dired-aux.el (dired-diff): When diffing files with backup
files, put all the backup files into the defaults so that they can
be reached with `M-n' from `read-file-name' (bug#24089).

etc/NEWS
lisp/dired-aux.el

index cd8cc317055f3d33b6c8674f4a7e8d483b754200..6d8379bd7d67204610ea4e6accebeeb376866fd9 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -235,6 +235,11 @@ time zones will use a form like "+0100" instead of "CET".
 
 ** Dired
 
+*** '=' ('dired-diff') will now put all backup files into the 'M-n' history.
+When using '=' on a file with backup files, the default file to use
+when diffing the newest backup file.  You can now use 'M-n' to quickly
+select a different backup file instead.
+
 +++
 *** New user option 'dired-maybe-use-globstar'.
 If set, enables globstar (recursive globbing) in shells that support
index c197ed04fe210c47a658c6e58f64a2d0769692b7..ab13b3e26ea56d0979bb14bbb5383b2ccafe6196 100644 (file)
@@ -134,7 +134,20 @@ the string of command switches used as the third argument of `diff'."
                               (file-name-directory default)
                             (dired-current-directory))
                        (dired-dwim-target-directory)))
-         (defaults (dired-dwim-target-defaults (list current) target-dir)))
+         (defaults (append
+                     (if (backup-file-name-p current)
+                         ;; This is a backup file -- put the other
+                         ;; main file, and the other backup files into
+                         ;; the `M-n' list.
+                         (delete (expand-file-name current)
+                                 (cons (expand-file-name
+                                        (file-name-sans-versions current))
+                                       (file-backup-file-names
+                                        (file-name-sans-versions current))))
+                       ;; Non-backup file -- use the backup files as
+                       ;; `M-n' candidates.
+                       (file-backup-file-names current))
+                     (dired-dwim-target-defaults (list current) target-dir))))
      (list
       (minibuffer-with-setup-hook
          (lambda ()