GNU bug report logs -
#11331
Emacs unnecessarily leaves behind stale auto-save files after crash recovery
Previous Next
Reported by: Kelly Dean <kellydeanch <at> yahoo.com>
Date: Tue, 24 Apr 2012 19:32:01 UTC
Severity: minor
Tags: moreinfo, patch
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 11331 in the body.
You can then email your comments to 11331 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11331
; Package
emacs
.
(Tue, 24 Apr 2012 19:32:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Kelly Dean <kellydeanch <at> yahoo.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 24 Apr 2012 19:32:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
I'm using Emacs on X on Debian 6 Stable. emacs-version says GNU Emacs 23.2.1 (i486-pc-linux-gnu, GTK+ Version 2.20.0) of 2010-12-11 on raven, modified by Debian.
Steps to reproduce the bug:
Open any writeable file in Emacs, modify it, and run do-auto-save.
kill -9 Emacs.
Restart Emacs, load the file, and run recover-this-file.
Save the file before the auto-save timeout.
Notice that the auto-save file remains, permanently, unless the buffer is later modified (which might not ever happen) and another auto-save operation overwrites the old auto-save file (which won't happen even if the buffer is modified, if the user saves the file before the auto-save timeout).
Desired behavior: delete the auto-save file (only if auto-save-visited-file-name is nil, of course) when the file is saved after being recovered, since the auto-save file no longer contains data which hasn't been saved to the primary file.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11331
; Package
emacs
.
(Sat, 02 Jun 2012 21:37:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 11331 <at> debbugs.gnu.org (full text, mbox):
This bug is reproducible on 24.1-rc1. (emacs-version reports "GNU Emacs 24.1.1 (i686-pc-linux-gnu, X toolkit, Xaw scroll bars) of 2012-06-01 on localhost")
Severity set to 'minor' from 'normal'
Request was from
Stefan Kangas <stefan <at> marxist.se>
to
control <at> debbugs.gnu.org
.
(Wed, 19 Aug 2020 10:53:01 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11331
; Package
emacs
.
(Fri, 16 Jul 2021 11:31:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 11331 <at> debbugs.gnu.org (full text, mbox):
Kelly Dean <kellydeanch <at> yahoo.com> writes:
> Notice that the auto-save file remains, permanently, unless the buffer
> is later modified (which might not ever happen) and another auto-save
> operation overwrites the old auto-save file (which won't happen even
> if the buffer is modified, if the user saves the file before the
> auto-save timeout).
This is still the case in Emacs 28:
(defun basic-save-buffer (&optional called-interactively)
[...]
(let ((recent-save (recent-auto-save-p))
[...]
;; If the auto-save file was recent before this command,
;; delete it now.
(delete-auto-save-file-if-necessary recent-save))
`recent-auto-save-p' will return nil here, so FORCE to
`delete-auto-save-file-if-necessary' is nil. If I'm reading the code
correctly, just passing in a t here would fix this issue.
(defun delete-auto-save-file-if-necessary (&optional force)
"Delete auto-save file for current buffer if `delete-auto-save-files' is t.
Normally delete only if the file was written by this Emacs since
the last real save, but optional arg FORCE non-nil means delete anyway."
So this is on purpose (presumably to avoid deleting other instances'
auto-save files or something)... but when we've just recovered from the
auto-save file, then it definitely should be deleted, I think.
I think... fixing this would entail `recover-file' setting something.
Either a buffer-local variable, or setting auto_save_modified... Hm!
`set-buffer-auto-saved'!
The following patch fixes the problem.
Does anybody have any comments to this approach?
diff --git a/lisp/files.el b/lisp/files.el
index ad02d373fd..be57763646 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -6508,7 +6508,8 @@ recover-file
(coding-system-for-read 'auto-save-coding))
(erase-buffer)
(insert-file-contents file-name nil)
- (set-buffer-file-coding-system coding-system))
+ (set-buffer-file-coding-system coding-system)
+ (set-buffer-auto-saved))
(after-find-file nil nil t))
(t (user-error "Recover-file canceled")))))
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) patch.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Fri, 16 Jul 2021 11:31:02 GMT)
Full text and
rfc822 format available.
Added tag(s) moreinfo.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Fri, 16 Jul 2021 11:31:03 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#11331
; Package
emacs
.
(Fri, 30 Jul 2021 12:08:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 11331 <at> debbugs.gnu.org (full text, mbox):
Lars Ingebrigtsen <larsi <at> gnus.org> writes:
> The following patch fixes the problem.
>
> Does anybody have any comments to this approach?
Nobody had in two weeks, so I pushed the proposed fix to Emacs 28.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
bug marked as fixed in version 28.1, send any further explanations to
11331 <at> debbugs.gnu.org and Kelly Dean <kellydeanch <at> yahoo.com>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Fri, 30 Jul 2021 12:08:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 28 Aug 2021 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 3 years and 296 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.