From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Visuwesh Newsgroups: gmane.emacs.bugs Subject: bug#52242: 29.0.50; Feature Request: Offer to run`diff-buffer-with-file' in `recover-this-file' prompt Date: Sun, 10 Dec 2023 18:57:56 +0530 Message-ID: <87o7eyuqzn.fsf@gmail.com> References: <8734wfwxi4.fsf@gmail.com> <87wmtqvaqb.fsf@gmail.com> <83h6kryb35.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5122"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 52242@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 10 14:29:15 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rCJrv-00019K-La for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 10 Dec 2023 14:29:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rCJrW-0006BW-5n; Sun, 10 Dec 2023 08:28:50 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rCJrT-0006B6-Tm for bug-gnu-emacs@gnu.org; Sun, 10 Dec 2023 08:28:47 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rCJrT-0004TY-KT for bug-gnu-emacs@gnu.org; Sun, 10 Dec 2023 08:28:47 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rCJrh-00068P-Oa for bug-gnu-emacs@gnu.org; Sun, 10 Dec 2023 08:29:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Visuwesh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 10 Dec 2023 13:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52242 X-GNU-PR-Package: emacs Original-Received: via spool by 52242-submit@debbugs.gnu.org id=B52242.170221490423532 (code B ref 52242); Sun, 10 Dec 2023 13:29:01 +0000 Original-Received: (at 52242) by debbugs.gnu.org; 10 Dec 2023 13:28:24 +0000 Original-Received: from localhost ([127.0.0.1]:49777 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCJr5-00067U-KF for submit@debbugs.gnu.org; Sun, 10 Dec 2023 08:28:24 -0500 Original-Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:60803) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rCJr2-00067G-U5 for 52242@debbugs.gnu.org; Sun, 10 Dec 2023 08:28:22 -0500 Original-Received: by mail-pl1-x642.google.com with SMTP id d9443c01a7336-1d0ccda19eeso22502665ad.1 for <52242@debbugs.gnu.org>; Sun, 10 Dec 2023 05:28:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702214881; x=1702819681; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=6ihA1hHwEcuKDOhsLEsTCEwGnU9r0PtfOFPiq86aixU=; b=Y4lIkMi/qSHCU4w/n5lIKzReDWTU9nGcGv61jn/GhZU6om+YCow5H5awoCMe8gzzkh jB/N2foD+0Rx79Toea41nlOwCJGDHSUnFuuYUc/yynD4pNOf4ECM/1zCVLjutXwi8/rg e9SwUcE9glMIPLhcAMcdE//BzAIeVZfIxaMYQimFkp+vDh361geE43A15zZiWEO8tu/5 /52ZLHetxcdk/IjWDjQUHzdqbUtbfteFudk1iPlsgR5E9oleLAN1epUedugA0OECbPlW uScaSEQwiiHyEJ451OTvaF7BnonUCst7RIRrzw1sJmppiKaygQj3nZBgISj1OYc6q8k5 qOag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702214881; x=1702819681; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6ihA1hHwEcuKDOhsLEsTCEwGnU9r0PtfOFPiq86aixU=; b=QbNIjqYAkhl/4NS//hjBEIgoNakm1NE87ecPFFwG7Tnk/KudIl/93Az/8nDWnuCvWd PfmhCMQZa1WztzCKyZkdUSx20typyIp9/tAy73ks35+QJLbfxpOjdj3VP0x5IE6Q3ld7 WifocMrIGjpJrVa5VX6gbyL6UYYolfFlbJmuzIIh6Fz62fY8PUEkB/SvYTfHq9VDqYK/ PJeGCgRaKzA5FK6odvf047pml8BmrOO1cf09FljhnaXUUbsNVAa32AuNxPNdofmeXwxz 9zjlcG+UuS8liX39jtttlGhgqSLS7rRHh9gOGv4mQBJu7PcSxrqZBxCzAW1zHgYtLG8v FhlA== X-Gm-Message-State: AOJu0Yy4IGuxSGVdueDk5arBf/N5rJeOCvesgrGtH9ty7nfXrL7zdzvU xCqBNKwnS5aQLBWMNnTaPvc= X-Google-Smtp-Source: AGHT+IGGSmJSrpDyNnF2k3sR3xPzCocy0EPAUIh3lDmeFMBF9l5JbWt5VitiCH0r4rKhinB+s4lmBQ== X-Received: by 2002:a17:902:e54a:b0:1d0:6ffe:1e8b with SMTP id n10-20020a170902e54a00b001d06ffe1e8bmr1519310plf.110.1702214880661; Sun, 10 Dec 2023 05:28:00 -0800 (PST) Original-Received: from localhost ([49.205.87.230]) by smtp.gmail.com with ESMTPSA id iz17-20020a170902ef9100b001cfc170c0cfsm4786601plb.119.2023.12.10.05.27.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 05:27:59 -0800 (PST) In-Reply-To: <83h6kryb35.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 09 Dec 2023 11:33:18 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:275920 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable [=E0=AE=9A=E0=AE=A9=E0=AE=BF =E0=AE=9F=E0=AE=BF=E0=AE=9A=E0=AE=AE=E0=AF=8D= =E0=AE=AA=E0=AE=B0=E0=AF=8D 09, 2023] Eli Zaretskii wrote: >> From: Visuwesh >> Date: Thu, 07 Dec 2023 11:02:28 +0530 >>=20 >> 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. > > Thanks, I have a few comments: Thanks for the review. >> 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 >>=20=20 >> 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. > > It is better to make the documentation of the 'diff' response separate > from the rest, since the original text doesn't describe the responses > at all, it only mentions the need for confirmation. > > So I suggest to leave the text starting at "Before asking for > confirmation" alone, and add a new paragraph after that one, like > this: > > When @kbd{M-x recover-file} asks for confirmation, if you respond > with @kbd{diff} or @kbd{=3D}, it shows the diffs between ... OK, I made it into a separate paragraph and added that it reprompts for confirmation. >> ++++ >> +** 'recover-file' can show diff between auto save file and current file. > ^^^^ > We use "diffs", plural. > >> +When answering the prompt with "diff" or "=3D", it now shows the diff > ^^^^ > Same here. Done. >> +between the auto save file and the current file. >> + (choices >> + '(("yes" ?y "recover auto save file") >> + ("no" ?n "don't recover auto save file") >> + ("diff" ?=3D "diff auto save file with c= urrent file"))) > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^= ^^^^^^^^^^^ > Maybe a better text would be > > show changes between auto save file and current file Thank you, that is indeed clear. I have now changed the help text to your suggestion. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Offer-to-show-diff-against-auto-save-in-recover-file.patch >From 49105b0b98c6cccfda028f2ed52fe3cbd403028b Mon Sep 17 00:00:00 2001 From: Visuwesh 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, 20 insertions(+), 3 deletions(-) diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 917e937d32d..2fc1550de61 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -1325,10 +1325,14 @@ 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 +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 29f4e5c0b66..39708d866d3 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 1cdcec23b11..83534e0080c 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" ?= "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 -- 2.42.0 --=-=-=--