From 0f014a79a3e93e21ef2ab8c826c333e744948aa2 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Mon, 24 Aug 2020 19:15:27 +0200 Subject: [PATCH] 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 cd8cc317055..6d8379bd7d6 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 c197ed04fe2..ab13b3e26ea 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 () -- 2.39.2