From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#21612: 24.5; Configuration variable to delete auto-save file when intentionally killing buffer Date: Sun, 22 Aug 2021 12:29:41 +0300 Message-ID: <83a6l9yghm.fsf@gnu.org> References: <87im05d0rr.fsf@gnus.org> <83fsv98roh.fsf@gnu.org> <878s11a44w.fsf@gnus.org> <838s118opm.fsf@gnu.org> <87k0kidiqm.fsf@gnus.org> <83sfz6512h.fsf@gnu.org> <874kbmdgak.fsf@gnus.org> <83o89u50fg.fsf@gnu.org> <87r1eqbz8q.fsf@gnus.org> <83h7fm4tpl.fsf@gnu.org> <87lf4yaenz.fsf@gnus.org> <83bl5u4s95.fsf@gnu.org> <87pmu98u01.fsf@gnus.org> <83h7fk1vob.fsf@gnu.org> <87eeao8cte.fsf@gnus.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5885"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 21612@debbugs.gnu.org, mrok4a@gmail.com, rms@gnu.org To: Lars Ingebrigtsen , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Aug 22 11:31:34 2021 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 1mHjpF-0001N9-6X for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 22 Aug 2021 11:31:33 +0200 Original-Received: from localhost ([::1]:39338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHjpC-0000Fc-Ut for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 22 Aug 2021 05:31:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHjok-0000FP-Gg for bug-gnu-emacs@gnu.org; Sun, 22 Aug 2021 05:31:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54864) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHjok-0003Ho-8y for bug-gnu-emacs@gnu.org; Sun, 22 Aug 2021 05:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mHjoj-0001co-TU for bug-gnu-emacs@gnu.org; Sun, 22 Aug 2021 05:31:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 22 Aug 2021 09:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21612 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 21612-submit@debbugs.gnu.org id=B21612.16296246096180 (code B ref 21612); Sun, 22 Aug 2021 09:31:01 +0000 Original-Received: (at 21612) by debbugs.gnu.org; 22 Aug 2021 09:30:09 +0000 Original-Received: from localhost ([127.0.0.1]:38177 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mHjns-0001bc-Oo for submit@debbugs.gnu.org; Sun, 22 Aug 2021 05:30:09 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:54826) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mHjnq-0001Zf-86 for 21612@debbugs.gnu.org; Sun, 22 Aug 2021 05:30:06 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:43560) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHjnk-0002O2-DQ; Sun, 22 Aug 2021 05:30:00 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3713 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHjnd-0006pB-LY; Sun, 22 Aug 2021 05:29:53 -0400 In-Reply-To: <87eeao8cte.fsf@gnus.org> (message from Lars Ingebrigtsen on Fri, 20 Aug 2021 15:29:01 +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" Xref: news.gmane.io gmane.emacs.bugs:212405 Archived-At: > From: Lars Ingebrigtsen > Cc: mrok4a@gmail.com, 21612@debbugs.gnu.org, rms@gnu.org > Date: Fri, 20 Aug 2021 15:29:01 +0200 > > I actually tried this instead of making sense of the code, and: > > emacs -Q /tmp/foo > insert bar > M-x do-auto-save > M-x not-modified > C-x k RET > > The auto-save file is not deleted. > > So I'm back to my second interpretation of the code -- I don't > understand under what condition it's actually triggered (if any). First, there seems to be an obvious logic bug there: /* Delete any auto-save file, if we saved it in this session. But not if the buffer is modified. */ if (STRINGP (BVAR (b, auto_save_file_name)) && BUF_AUTOSAVE_MODIFF (b) != 0 && BUF_SAVE_MODIFF (b) < BUF_AUTOSAVE_MODIFF (b) && BUF_SAVE_MODIFF (b) < BUF_MODIFF (b) <<<<<<<<<<<<<<<<<<<<<<<<<< && NILP (Fsymbol_value (intern ("auto-save-visited-file-name")))) { Lisp_Object delete; delete = Fsymbol_value (intern ("delete-auto-save-files")); if (! NILP (delete)) internal_delete_file (BVAR (b, auto_save_file_name)); } The condition I emphasized above should be reversed, because it means the buffer _is_ modified, whereas according to the comment we need to test that it _isn't_. Right? And second, I think the condition before it should be changed to say && BUF_SAVE_MODIFF (b) <= BUF_AUTOSAVE_MODIFF (b) I see no reason to reject the situation where the two are equal. Come to think of this, I don't see why we need this last condition at all. In its current form it means that the buffer was auto-saved since the last save, but if it was auto-saved _before_ the last save, it means the auto-save file is even less important to keep, right? So maybe we should remove that condition. Adding Stefan, who considered this stuff 11 years ago. Stefan, any comments? (There's also bug#5314 that's related to this.)