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: Thu, 07 Dec 2023 11:02:28 +0530 Message-ID: <87wmtqvaqb.fsf@gmail.com> References: <8734wfwxi4.fsf@gmail.com> 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="33239"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 52242@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 07 06:33:12 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 1rB70a-0008U4-7r for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 07 Dec 2023 06:33:12 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rB70F-0004tI-MF; Thu, 07 Dec 2023 00:32:51 -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 1rB70E-0004t4-NI for bug-gnu-emacs@gnu.org; Thu, 07 Dec 2023 00:32:50 -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 1rB70E-0006d5-EI for bug-gnu-emacs@gnu.org; Thu, 07 Dec 2023 00:32:50 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rB70Q-0000fS-7d for bug-gnu-emacs@gnu.org; Thu, 07 Dec 2023 00:33:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Visuwesh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Dec 2023 05:33:02 +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.17019271782554 (code B ref 52242); Thu, 07 Dec 2023 05:33:02 +0000 Original-Received: (at 52242) by debbugs.gnu.org; 7 Dec 2023 05:32:58 +0000 Original-Received: from localhost ([127.0.0.1]:40864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rB70L-0000f8-Es for submit@debbugs.gnu.org; Thu, 07 Dec 2023 00:32:57 -0500 Original-Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:56747) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rB70I-0000et-Aw for 52242@debbugs.gnu.org; Thu, 07 Dec 2023 00:32:55 -0500 Original-Received: by mail-pf1-x441.google.com with SMTP id d2e1a72fcca58-6ce934e9d51so248746b3a.1 for <52242@debbugs.gnu.org>; Wed, 06 Dec 2023 21:32:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701927156; x=1702531956; darn=debbugs.gnu.org; h=mime-version:user-agent:references:message-id:date:in-reply-to :subject:to:from:from:to:cc:subject:date:message-id:reply-to; bh=6bfyeC0YqoM9P/Io7OGQ93LjXC3WagQFSKpUDqXdCAE=; b=WW1q5uuEiKKemA4GRxMK5CWUVuzg5Hl/JlKffx9FDgWAcLLBrP8Bb9+UINMiZYHs8X Dd3grw2ozNb71dKQb4BkAuV1TaE70HsNcFcd8bhfPvefZy8wocihTb/u6gBGEHOSk8es zOEoZFFb5t3Khhoq+Hys1XXPxwvmZZGW8AtnFf8kouSwpRbNI4C4iEo5o5gpLxLm/8Cx dirovyBep9dScYwpI09jki19/iElyvmNC0vsaXDIAfUgIrr/Ya9lIy+PwxDgv80PV0SU dR4RNTm8Iobno0T2bxHoHzE4rsuPrsLU7qTgRGC2P3ye+JIHHiZdYzcIJ5iSWMWM/0ic +JXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701927156; x=1702531956; h=mime-version:user-agent:references:message-id:date:in-reply-to :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6bfyeC0YqoM9P/Io7OGQ93LjXC3WagQFSKpUDqXdCAE=; b=GElKs2jj7HxdUCDxd4eISQVUjdM60YN4kFnQJLQ51f0Dyl4yJBTloChQPC95fsDHU6 0ETBOy6JtCle3Q8H9+lx4rsUSRIbSK2V8MyyPzrjGpxu5Q6nax1TTobshJp9HkmmimIa 2epFlerFqU/Fnz4CQ14/Dvd+4Bx8WEiO2aLbFCdPcingMJP59wQYvDLvi7Ct6m9gMt/H /59N1fKOrxFdrs7ssIHZ6b+xApK7CKu76laTbtIEPxucW5qmUlrIRGbq8RnfGSdiUwaw Yfg7hVjl64aeMyXSdRjB8umCOfV9aCBDlthXAIFa0eZBS0HaSqpTqtEySEmIAg+rdnYa rhNg== X-Gm-Message-State: AOJu0Yxl7HUMxrsssTKCMFZ7WqHEsFzQxBrmoYQuEdMa+1G+unITV6/c wBcFcsFBsNsmvPXvaoHRF47gif76kx04Qg== X-Google-Smtp-Source: AGHT+IFoGiSh8e1NP1xdSedAve7Qe8+WyLTyatkEguh/YLFV0q8dMfVV5aTeGeP0COUTuLVMk9XJ9Q== X-Received: by 2002:a05:6a21:a58a:b0:18f:da50:fbd7 with SMTP id gd10-20020a056a21a58a00b0018fda50fbd7mr2261752pzc.33.1701927155600; Wed, 06 Dec 2023 21:32:35 -0800 (PST) Original-Received: from localhost ([115.240.90.130]) by smtp.gmail.com with ESMTPSA id u1-20020a170902e5c100b001d05bb77b43sm397804plf.19.2023.12.06.21.32.34 for <52242@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 21:32:34 -0800 (PST) In-Reply-To: <8734wfwxi4.fsf@gmail.com> (Visuwesh's message of "Wed, 06 Dec 2023 13:52:59 +0530") 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:275641 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable [=E0=AE=AA=E0=AF=81=E0=AE=A4=E0=AE=A9=E0=AF=8D =E0=AE=9F=E0=AE=BF=E0=AE=9A= =E0=AE=AE=E0=AF=8D=E0=AE=AA=E0=AE=B0=E0=AF=8D 06, 2023] Visuwesh wrote: > [=E0=AE=B5=E0=AE=BF=E0=AE=AF=E0=AE=BE=E0=AE=B4=E0=AE=A9=E0=AF=8D =E0=AE= =9F=E0=AE=BF=E0=AE=9A=E0=AE=AE=E0=AF=8D=E0=AE=AA=E0=AE=B0=E0=AF=8D 02, 2021= ] Visuwesh wrote: > >> `recover-this-file' quite helpfully shows the time of creation of the >> auto-save file.=C2=A0 However, this is not always enough to decide wheth= er 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.=C2=A0 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. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Offer-to-show-diff-against-auto-save-in-recover-file.patch >From 60d90c030a5b9a86a778df8650a597e922f2a907 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, 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. + * 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 --=-=-=--