emacs-diffs
[Top][All Lists]
Advanced

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

master c4541a35770: Offer to show diff against auto-save in recover-file


From: Eli Zaretskii
Subject: master c4541a35770: Offer to show diff against auto-save in recover-file
Date: Sat, 16 Dec 2023 07:36:25 -0500 (EST)

branch: master
commit c4541a35770fe7925f733fcdaa9e4e3348a3c85c
Author: Visuwesh <visuweshm@gmail.com>
Commit: Eli Zaretskii <eliz@gnu.org>

    Offer to show diff against auto-save in recover-file
    
    * lisp/files.el (recover-file): Show diff against the selected auto
    save file.  (Bug#52242)
    
    * doc/emacs/files.texi (Recover): Document the new feature.
    
    * etc/NEWS: Announce the new feature.
---
 doc/emacs/files.texi |  4 ++++
 etc/NEWS             |  5 +++++
 lisp/files.el        | 10 +++++++++-
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index 917e937d32d..832c189ce49 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -1329,6 +1329,10 @@ directory listing describing the specified file and the 
auto-save file,
 so you can compare their sizes and dates.  If the auto-save file
 is older, @kbd{M-x recover-file} does not offer to read it.
 
+When @kbd{M-x recover-file} asks for confirmation, if you answer with
+@kbd{diff} or @kbd{=}, it shows the diffs between @var{file} and its
+auto-save file @file{#@var{file}#} and reprompts you for confirmation.
+
 @findex recover-session
   If Emacs or the computer crashes, you can recover all the files you
 were editing from their auto save files with the command @kbd{M-x
diff --git a/etc/NEWS b/etc/NEWS
index 29b3d6676de..26a97206b47 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -258,6 +258,11 @@ called in the '--eval' expression, which is useful when 
those
 arguments contain arbitrary characters that otherwise might require
 elaborate and error-prone escaping (to protect them from the shell).
 
++++
+** 'recover-file' can show diffs between auto save file and current file.
+When answering the prompt with "diff" or "=", it now shows the diffs
+between the auto save file and the current file.
+
 
 * Editing Changes in Emacs 30.1
 
diff --git a/lisp/files.el b/lisp/files.el
index f87e7807301..21f3376016c 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -7083,7 +7083,15 @@ auto-save file, if that is more recent than the visited 
file."
            #'(lambda (window _value)
                (with-selected-window window
                  (unwind-protect
-                     (yes-or-no-p (format "Recover auto save file %s? " 
file-name))
+                      (let ((prompt (format "Recover auto save file %s? " 
file-name))
+                            (choices
+                             '(("yes" ?y "recover auto save file")
+                               ("no" ?n "don't recover auto save file")
+                               ("diff" ?= "show changes between auto save file 
and current file")))
+                            ans)
+                        (while (equal "diff" (setq ans (read-answer prompt 
choices)))
+                          (diff file file-name))
+                        (equal ans "yes"))
                    (when (window-live-p window)
                      (quit-restore-window window 'kill)))))
            (with-current-buffer standard-output



reply via email to

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