From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#18141: 24.4.50; saving .gz file breaks file coding Date: Thu, 07 Aug 2014 22:37:03 +0300 Message-ID: <83r40sm6qo.fsf@gnu.org> References: <9pzjfrwvsl.fsf@fencepost.gnu.org> <83iom5ptwv.fsf@gnu.org> <83tx5po5eo.fsf@gnu.org> <83ha1onxgg.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1407440248 14454 80.91.229.3 (7 Aug 2014 19:37:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 7 Aug 2014 19:37:28 +0000 (UTC) Cc: 18141@debbugs.gnu.org, vincent@vinc17.net, yamaoka@jpl.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 07 21:37:16 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XFTUx-00028l-I7 for geb-bug-gnu-emacs@m.gmane.org; Thu, 07 Aug 2014 21:37:15 +0200 Original-Received: from localhost ([::1]:47945 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFTUx-0001wt-5G for geb-bug-gnu-emacs@m.gmane.org; Thu, 07 Aug 2014 15:37:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFTUp-0001va-7v for bug-gnu-emacs@gnu.org; Thu, 07 Aug 2014 15:37:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XFTUk-00075q-Ff for bug-gnu-emacs@gnu.org; Thu, 07 Aug 2014 15:37:07 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55601) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFTUk-00075j-CX for bug-gnu-emacs@gnu.org; Thu, 07 Aug 2014 15:37:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XFTUj-0007BS-TU for bug-gnu-emacs@gnu.org; Thu, 07 Aug 2014 15:37:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Aug 2014 19:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18141 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 18141-submit@debbugs.gnu.org id=B18141.140744021927603 (code B ref 18141); Thu, 07 Aug 2014 19:37:01 +0000 Original-Received: (at 18141) by debbugs.gnu.org; 7 Aug 2014 19:36:59 +0000 Original-Received: from localhost ([127.0.0.1]:34311 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XFTUg-0007B8-1H for submit@debbugs.gnu.org; Thu, 07 Aug 2014 15:36:59 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:60985) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XFTUd-0007Ar-64 for 18141@debbugs.gnu.org; Thu, 07 Aug 2014 15:36:55 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0N9Y00M00BT63V00@a-mtaout22.012.net.il> for 18141@debbugs.gnu.org; Thu, 07 Aug 2014 22:36:48 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0N9Y00LLTBTCAZA0@a-mtaout22.012.net.il>; Thu, 07 Aug 2014 22:36:48 +0300 (IDT) In-reply-to: X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:92283 Archived-At: > From: Stefan Monnier > Cc: rgm@gnu.org, 18141@debbugs.gnu.org, vincent@vinc17.net, yamaoka@jpl.org > Date: Thu, 07 Aug 2014 15:08:41 -0400 > > > Why not move the call to backup-buffer (and surrounding code that > > deals with backup complications) from basic-save-buffer-2 to a > > separate function, and then call that function directly from > > write-region, right before it is about to write the new contents? > > That's the hook I suggested. > It's indeed a valid approach. But it suffers from two problems: > - currently write-region doesn't itself perform backups, so if we make > it do them always, it's an incompatible change. > - if write-region sometimes performs backups, it'd probably be > controlled by some dynamic-scoped var (e.g. a hook), in which case > we could get "spurious" backups if write-region gets called during the > execution of write-region. We could add a new optional argument to write-region to control whether backup is performed. > > While at that, we should IMO make the backup-then-write sequence a > > transaction, by using the suitable unwind-protect functions, and > > perhaps also make sure that unwind-protect function runs if Emacs is > > killed half-way through the sequence, to keep the transaction promise. > > I'm not terribly worried about this "time window" especially since > I think it's pretty clear that we can't completely eliminate it anyway. I think users generally expect this to be a transaction. And at least on Posix platforms, where rename is an atomic operation, we can achieve this, or come pretty close.