]> git.eshelyaron.com Git - emacs.git/commitdiff
Offer to show diff against auto-save in recover-file
authorVisuwesh <visuweshm@gmail.com>
Wed, 6 Dec 2023 08:15:03 +0000 (13:45 +0530)
committerEshel Yaron <me@eshelyaron.com>
Sat, 16 Dec 2023 19:16:06 +0000 (20:16 +0100)
* 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.

(cherry picked from commit c4541a35770fe7925f733fcdaa9e4e3348a3c85c)

doc/emacs/files.texi
etc/NEWS
lisp/files.el

index 917e937d32df07a8896231911662bfe1d34139f4..832c189ce499393e06579b0f0dcfbd082a725b98 100644 (file)
@@ -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
index 7edcd6c9dd8635d341d92b9127cbbc1ccd46a470..a56dab1b58c585454108e590ad09d580957f7521 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -271,6 +271,12 @@ customize this option to nil.
 For example, 'jump-to-register' now only shows registers that you can
 actually jump to in the *Register Preview* buffer.
 
++++
+** '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.
+
+
 \f
 * Editing Changes in Emacs 30.1
 
index f87e7807301a071f3e8257d40a81f22610483e6f..21f3376016c7f0f14d60decf0a14ba3b39ac8f43 100644 (file)
@@ -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