unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Visuwesh <visuweshm@gmail.com>
To: 52242@debbugs.gnu.org
Subject: bug#52242: 29.0.50; Feature Request: Offer to run`diff-buffer-with-file' in `recover-this-file' prompt
Date: Thu, 07 Dec 2023 11:02:28 +0530	[thread overview]
Message-ID: <87wmtqvaqb.fsf@gmail.com> (raw)
In-Reply-To: <8734wfwxi4.fsf@gmail.com> (Visuwesh's message of "Wed, 06 Dec 2023 13:52:59 +0530")

[-- Attachment #1: Type: text/plain, Size: 868 bytes --]

[புதன் டிசம்பர் 06, 2023] Visuwesh wrote:

> [வியாழன் டிசம்பர் 02, 2021] Visuwesh wrote:
>
>> `recover-this-file' quite helpfully shows the time of creation of the
>> auto-save file.  However, this is not always enough to decide whether I
>> should recover from said auto-save file since there's no way of knowing
>> if the changes in auto-save file are desirable [1] so I end up answering
>> yes, then run `diff-buffer-with-file' anyway.  I think having a
>> `diff-buffer-with-file' option like `save-some-buffers' would be a
>> quality-of-life improvement.
>
> Please find attached path that uses read-answer to present the diff.

I didn't notice that recover-file was covered in the Emacs manual, I
have now updated the manual and marked the NEWS entry accordingly in the
attached patch.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Offer-to-show-diff-against-auto-save-in-recover-file.patch --]
[-- Type: text/x-diff, Size: 3027 bytes --]

From 60d90c030a5b9a86a778df8650a597e922f2a907 Mon Sep 17 00:00:00 2001
From: Visuwesh <visuweshm@gmail.com>
Date: Wed, 6 Dec 2023 13:45:03 +0530
Subject: [PATCH] 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 |  8 +++++---
 etc/NEWS             |  5 +++++
 lisp/files.el        | 10 +++++++++-
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index 917e937d32d..c791a6f1c98 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -1325,9 +1325,11 @@ Recover
 @end example
 
   Before asking for confirmation, @kbd{M-x recover-file} displays a
-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.
+directory listing describing the specified file and the auto-save
+file, so you can compare their sizes and dates.  If you answer
+@kbd{diff}, it shows the diff between @var{file} and its auto-save
+file @file{#@var{file}#}.  If the auto-save file is older, @kbd{M-x
+recover-file} does not offer to read it.
 
 @findex recover-session
   If Emacs or the computer crashes, you can recover all the files you
diff --git a/etc/NEWS b/etc/NEWS
index 29f4e5c0b66..f69595ef188 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 diff between auto save file and current file.
+When answering the prompt with "diff" or "=", it now shows the diff
+between the auto save file and the current file.
+
 \f
 * Editing Changes in Emacs 30.1
 
diff --git a/lisp/files.el b/lisp/files.el
index 1cdcec23b11..d70524e4775 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -7083,7 +7083,15 @@ recover-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" ?= "diff auto save file with 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
-- 
2.42.0


  reply	other threads:[~2023-12-07  5:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-02 12:28 bug#52242: 29.0.50; Feature Request: Offer to run`diff-buffer-with-file' in `recover-this-file' prompt Visuwesh via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-06  8:22 ` Visuwesh
2023-12-07  5:32   ` Visuwesh [this message]
2023-12-09  9:33     ` Eli Zaretskii
2023-12-10 13:27       ` Visuwesh
2023-12-11  4:14         ` Visuwesh
2023-12-16 12:36           ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wmtqvaqb.fsf@gmail.com \
    --to=visuweshm@gmail.com \
    --cc=52242@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).