* bug#52242: 29.0.50; Feature Request: Offer to run`diff-buffer-with-file' in `recover-this-file' prompt @ 2021-12-02 12:28 Visuwesh via Bug reports for GNU Emacs, the Swiss army knife of text editors 2023-12-06 8:22 ` Visuwesh 0 siblings, 1 reply; 7+ messages in thread From: Visuwesh via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-12-02 12:28 UTC (permalink / raw) To: 52242 `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. Thanks. [1] I fat finger my keyboard quite a lot and end up garbling the file even after explicitly saving the buffer. When I open the file in a new Emacs session again, I get suggested to `recover-this-file' and 8/10 times, I have to undo. Having a diff option directly in the prompt would save some keystrokes. In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27, cairo version 1.16.0) Repository revision: da67e888d5360297cdf20cd3d2a1148727d16e5a Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12012000 System Description: NixOS 21.11 (Porcupine) Configured using: 'configure --prefix=/nix/store/mlv737k3wph8lhxi2lm9942kbm31wmdz-emacs-gcc-20211030.0 --disable-build-details --with-modules --with-x-toolkit=gtk3 --with-xft --with-cairo --with-native-compilation' Configured features: CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB Important settings: value of $EMACSLOADPATH: value of $EMACSNATIVELOADPATH: /nix/store/hagxad2bnmdwy79yjkvkwjjynxpik7fw-emacs-packages-deps/share/emacs/native-lisp:: value of $LANG: en_GB.UTF-8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: TeX-PDF-mode: t recentf-mode: t paredit-mode: t eros-mode: t flymake-mode: t hl-todo-mode: t pdf-occur-global-minor-mode: t shell-dirtrack-mode: t minibuffer-depth-indicate-mode: t repeat-mode: t display-time-mode: t display-battery-mode: t straight-use-package-mode: t straight-package-neutering-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t transient-mark-mode: t abbrev-mode: t Load-path shadows: /home/viz/.nix-profile/share/emacs/site-lisp/site-start hides /nix/store/hagxad2bnmdwy79yjkvkwjjynxpik7fw-emacs-packages-deps/share/emacs/site-lisp/site-start /home/viz/lib/emacs/straight/build/map/map hides /nix/store/mlv737k3wph8lhxi2lm9942kbm31wmdz-emacs-gcc-20211030.0/share/emacs/29.0.50/lisp/emacs-lisp/map /home/viz/lib/emacs/straight/build/let-alist/let-alist hides /nix/store/mlv737k3wph8lhxi2lm9942kbm31wmdz-emacs-gcc-20211030.0/share/emacs/29.0.50/lisp/emacs-lisp/let-alist Features: (shadow sort emacsbug sendmail reporter preview tex-buf latex-mode-expansions latex latex-flymake tex-ispell tex-style tex crm trace edebug hippie-exp re-builder holidays hol-loaddefs cal-move autoload math-delimiters cursor-sensor org-pdftools pdf-annot facemenu org-noter executable time-stamp comp comp-cstr cl-print debug backtrace thai-util thai-word misearch multi-isearch view mule-util ement-room-list ement ement-notify ement-room ewoc ement-api ement-structs ement-macros plz dns ts s etags fileloop xref rect mail-extr wdired dired-aux shortdoc dired-x help-fns radix-tree expand-region text-mode-expansions cc-mode-expansions the-org-mode-expansions er-basic-expansions expand-region-core expand-region-custom pulse color reveal recentf tree-widget vc-git diff-mode vc-dispatcher server paredit edmacro kmacro eros checkdoc lisp-mnt flymake-proc flymake project hl-todo writegood-mode-autoloads ement-autoloads ts-autoloads s-autoloads map-autoloads plz-autoloads transmission-autoloads lua-mode-autoloads nix-mode-autoloads magit-section-autoloads racket-mode-autoloads eros-autoloads flymake-shellcheck-autoloads avy avy-autoloads siege-mode siege-mode-autoloads paredit-autoloads expand-region-autoloads filladapt-autoloads compose quail notifications org-capture doct warnings org-refile org-clock scroll-other-window org-pdftools-autoloads org-noter-autoloads finder-inf pdf-occur ibuf-ext ibuffer ibuffer-loaddefs tablist tablist-filter semantic/wisent/comp semantic/wisent semantic/wisent/wisent semantic/util-modes semantic/util semantic semantic/tag semantic/lex semantic/fw mode-local cedet pdf-isearch let-alist pdf-misc imenu pdf-tools package url-handlers compile cus-edit pdf-view bookmark pp pdf-cache pdf-info tq pdf-util pdf-macs pdf-tools-autoloads let-alist-autoloads tablist-autoloads math-delimiters-autoloads doct-autoloads valign flyspell ispell face-remap goto-addr org-indent org-num org-element avl-tree generator ol-eww eww xdg url-queue thingatpt mm-url ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect gnus-search eieio-opt speedbar ezimage dframe gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-sum shr kinsoku svg dom browse-url gnus-group gnus-undo gnus-start gnus-dbus gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo parse-time gnus-spec gnus-int gnus-range message rmc puny rfc822 mml mml-sec epa epg rfc6068 epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader gnus-win gnus nnheader gnus-util rmail rmail-loaddefs rfc2047 rfc2045 ietf-drums text-property-search mail-utils mm-util mail-prsvr wid-edit ol-docview doc-view jka-compr image-mode exif dired dired-loaddefs ol-bibtex ol-bbdb ol-w3m ol-doi org-link-doi ob-C cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs ob-shell shell ob-racket dash async ob-async org-starless cdlatex texmathp org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-footnote org-src ob-comint org-pcomplete pcomplete comint ansi-color ring org-list org-faces org-entities noutline outline org-version ob-emacs-lisp ob-core ob-eval org-table oc-basic bibtex iso8601 time-date ol org-keys oc org-compat advice org-macs org-loaddefs find-func ob-async-autoloads dash-autoloads async-autoloads emacs-ob-racket-autoloads valign-autoloads easy-mmode org-starless-autoloads cdlatex-autoloads auctex-autoloads tex-site tempo derived mb-depth cus-load repeat visual-fill-autoloads olivetti-autoloads hl-todo-autoloads moody-autoloads time format-spec battery dbus filenotify xml disp-table vz-nh-theme shell-command+ shell-command-plus-autoloads icalendar diary-lib diary-loaddefs cal-menu calendar cal-loaddefs url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf url-util url-parse auth-source eieio eieio-core eieio-loaddefs password-cache json map url-vars mailcap rx chemtable chemtable-autoloads molar-mass-autoloads pcase straight-autoloads info cl-seq cl-extra help-mode straight cl-macs cl-loaddefs cl-lib seq gv subr-x byte-opt bytecomp byte-compile cconv iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty make-network-process native-compile emacs) Memory information: ((conses 16 1208185 292637) (symbols 48 42228 4) (strings 32 303314 43731) (string-bytes 1 8562492) (vectors 16 108614) (vector-slots 8 2355085 365629) (floats 8 691 1499) (intervals 56 52079 12887) (buffers 992 50)) ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#52242: 29.0.50; Feature Request: Offer to run`diff-buffer-with-file' in `recover-this-file' prompt 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 0 siblings, 1 reply; 7+ messages in thread From: Visuwesh @ 2023-12-06 8:22 UTC (permalink / raw) To: 52242 [-- Attachment #1: Type: text/plain, Size: 621 bytes --] [வியாழன் டிசம்பர் 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. [-- 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: 2039 bytes --] From d64f8a1307ab82216b5f97982494945547810f64 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 * etc/NEWS: Announce the new feature. --- etc/NEWS | 4 ++++ lisp/files.el | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/etc/NEWS b/etc/NEWS index 29f4e5c0b66..6c2a584c355 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -258,6 +258,10 @@ 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-this-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 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#52242: 29.0.50; Feature Request: Offer to run`diff-buffer-with-file' in `recover-this-file' prompt 2023-12-06 8:22 ` Visuwesh @ 2023-12-07 5:32 ` Visuwesh 2023-12-09 9:33 ` Eli Zaretskii 0 siblings, 1 reply; 7+ messages in thread From: Visuwesh @ 2023-12-07 5:32 UTC (permalink / raw) To: 52242 [-- 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 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#52242: 29.0.50; Feature Request: Offer to run`diff-buffer-with-file' in `recover-this-file' prompt 2023-12-07 5:32 ` Visuwesh @ 2023-12-09 9:33 ` Eli Zaretskii 2023-12-10 13:27 ` Visuwesh 0 siblings, 1 reply; 7+ messages in thread From: Eli Zaretskii @ 2023-12-09 9:33 UTC (permalink / raw) To: Visuwesh; +Cc: 52242 > From: Visuwesh <visuweshm@gmail.com> > Date: Thu, 07 Dec 2023 11:02:28 +0530 > > 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: > 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. 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{=}, it shows the diffs between ... > ++++ > +** 'recover-file' can show diff between auto save file and current file. ^^^^ We use "diffs", plural. > +When answering the prompt with "diff" or "=", it now shows the diff ^^^^ Same here. > +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" ?= "diff auto save file with current file"))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Maybe a better text would be 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")) Thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#52242: 29.0.50; Feature Request: Offer to run`diff-buffer-with-file' in `recover-this-file' prompt 2023-12-09 9:33 ` Eli Zaretskii @ 2023-12-10 13:27 ` Visuwesh 2023-12-11 4:14 ` Visuwesh 0 siblings, 1 reply; 7+ messages in thread From: Visuwesh @ 2023-12-10 13:27 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 52242 [-- Attachment #1: Type: text/plain, Size: 2752 bytes --] [சனி டிசம்பர் 09, 2023] Eli Zaretskii wrote: >> From: Visuwesh <visuweshm@gmail.com> >> Date: Thu, 07 Dec 2023 11:02:28 +0530 >> >> 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 >> >> 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{=}, 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 "=", 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" ?= "diff auto save file with current 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. [-- 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: 3156 bytes --] From 49105b0b98c6cccfda028f2ed52fe3cbd403028b 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, 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. + \f * 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 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#52242: 29.0.50; Feature Request: Offer to run`diff-buffer-with-file' in `recover-this-file' prompt 2023-12-10 13:27 ` Visuwesh @ 2023-12-11 4:14 ` Visuwesh 2023-12-16 12:36 ` Eli Zaretskii 0 siblings, 1 reply; 7+ messages in thread From: Visuwesh @ 2023-12-11 4:14 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 52242 [-- Attachment #1: Type: text/plain, Size: 193 bytes --] [ஞாயிறு டிசம்பர் 10, 2023] Visuwesh wrote: Just noticed that I had an unrelated filling change sneak in, the attached patch omits that. Sorry for the noise. [-- 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: 2853 bytes --] From d4ce87ae26c3c43851841432d4f3e1b3f5404f75 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 | 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 @@ Recover 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. + \f * 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 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#52242: 29.0.50; Feature Request: Offer to run`diff-buffer-with-file' in `recover-this-file' prompt 2023-12-11 4:14 ` Visuwesh @ 2023-12-16 12:36 ` Eli Zaretskii 0 siblings, 0 replies; 7+ messages in thread From: Eli Zaretskii @ 2023-12-16 12:36 UTC (permalink / raw) To: Visuwesh; +Cc: 52242-done > From: Visuwesh <visuweshm@gmail.com> > Cc: 52242@debbugs.gnu.org > Date: Mon, 11 Dec 2023 09:44:50 +0530 > > [ஞாயிறு டிசம்பர் 10, 2023] Visuwesh wrote: > > Just noticed that I had an unrelated filling change sneak in, the > attached patch omits that. Sorry for the noise. Thanks, installed on the master branch, and closing the bug. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-12-16 12:36 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
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).