emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 0f014a7 2/2: Extend the default value in dired-diff to all the ba


From: Lars Ingebrigtsen
Subject: master 0f014a7 2/2: Extend the default value in dired-diff to all the backup files
Date: Mon, 24 Aug 2020 13:15:43 -0400 (EDT)

branch: master
commit 0f014a79a3e93e21ef2ab8c826c333e744948aa2
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Extend the default value in dired-diff to all the backup files
    
    * 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          |  5 +++++
 lisp/dired-aux.el | 15 ++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/etc/NEWS b/etc/NEWS
index cd8cc31..6d8379b 100644
--- 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
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index c197ed0..ab13b3e 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -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 ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]