From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: backup method Date: Tue, 01 Feb 2005 09:09:53 -0500 Message-ID: <878y681iga.fsf-monnier+emacs@gnu.org> References: <20050127000210.GA6167@boetes.org> <200501270045.j0R0jIq06197@raven.dms.auburn.edu> <20050127015432.GB6167@boetes.org> <20050128035618.GI6167@boetes.org> <20050129060851.GQ6167@boetes.org> <200501291842.j0TIgVw09020@raven.dms.auburn.edu> <20050129225259.GT6167@boetes.org> <87r7k3zti5.fsf-monnier+emacs@gnu.org> <874qgyxw24.fsf-monnier+emacs@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1107267384 27235 80.91.229.2 (1 Feb 2005 14:16:24 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 1 Feb 2005 14:16:24 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 01 15:16:23 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1CvykP-00050t-2p for ged-emacs-devel@m.gmane.org; Tue, 01 Feb 2005 15:11:20 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CvyxK-0008Kx-OV for ged-emacs-devel@m.gmane.org; Tue, 01 Feb 2005 09:24:38 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Cvywg-00088w-9d for emacs-devel@gnu.org; Tue, 01 Feb 2005 09:23:58 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1CvywW-00084W-Vn for emacs-devel@gnu.org; Tue, 01 Feb 2005 09:23:50 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CvywW-000848-Ry for emacs-devel@gnu.org; Tue, 01 Feb 2005 09:23:48 -0500 Original-Received: from [209.226.175.184] (helo=tomts22-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Cvyj9-0001wj-8u; Tue, 01 Feb 2005 09:09:59 -0500 Original-Received: from alfajor ([67.71.119.71]) by tomts22-srv.bellnexxia.net (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP id <20050201140953.HMUO1919.tomts22-srv.bellnexxia.net@alfajor>; Tue, 1 Feb 2005 09:09:53 -0500 Original-Received: by alfajor (Postfix, from userid 1000) id BB3C2D7345; Tue, 1 Feb 2005 09:09:53 -0500 (EST) Original-To: rms@gnu.org In-Reply-To: (Richard Stallman's message of "Tue, 01 Feb 2005 08:30:35 -0500") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org X-MailScanner-To: ged-emacs-devel@m.gmane.org Xref: main.gmane.org gmane.emacs.devel:32704 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:32704 > Simply writing a file in such a directory would raise the same issue, > right? If so, it really has nothing to do with backups. Agreed. > I think the fix is to treat files in such directories as precious. > Not because they really are precious, but because the handling of a > precious file might avoid the problem. OK. > ! (set-default-file-modes ?\700) > ! ;; Try various temporary names. > ! ;; This code follows the example of make-temp-file, > ! ;; but it calls write-region in the appropriate way > ! ;; for saving the buffer. > ! (while (condition-case () > ! (progn > ! (setq tempname > ! (make-temp-name > ! (expand-file-name "tmp" dir))) > ! (write-region (point-min) (point-max) > ! tempname nil realname > ! buffer-file-truename 'excl) > ! nil) > ! (file-already-exists t)) > ! ;; The file was somehow created by someone else between > ! ;; `make-temp-name' and `write-region', let's try again. > ! nil) Any reason why you didn't use make-temp-file? Stefan