From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: JUAN-LEON Lahoz Garcia Newsgroups: gmane.emacs.devel Subject: Problem at backup-buffer for writable files in not writable dirs Date: Thu, 10 Mar 2005 10:17:37 +0100 Message-ID: NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1110447133 2975 80.91.229.2 (10 Mar 2005 09:32:13 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 10 Mar 2005 09:32:13 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 10 10:32:12 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1D9K1N-0000b6-FC for ged-emacs-devel@m.gmane.org; Thu, 10 Mar 2005 10:31:57 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D9KGD-00084c-8U for ged-emacs-devel@m.gmane.org; Thu, 10 Mar 2005 04:47:17 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1D9Ju1-00034v-Pl for emacs-devel@gnu.org; Thu, 10 Mar 2005 04:24:22 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1D9Jtz-00034D-1K for emacs-devel@gnu.org; Thu, 10 Mar 2005 04:24:21 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D9Jts-00033i-Pa for emacs-devel@gnu.org; Thu, 10 Mar 2005 04:24:14 -0500 Original-Received: from [129.188.136.8] (helo=motgate8.mot.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1D9JfD-00007y-DM for emacs-devel@gnu.org; Thu, 10 Mar 2005 04:09:03 -0500 Original-Received: from az33exr03.mot.com (az33exr03.mot.com [10.64.251.233]) by motgate8.mot.com (Motorola/Motgate8) with ESMTP id j2A9BE2C000869 for ; Thu, 10 Mar 2005 02:11:14 -0700 (MST) Original-Received: from zes06exm01.madrid.ecid.cig.mot.com ([10.161.1.12]) by az33exr03.mot.com (8.13.1/8.13.0) with ESMTP id j2A9ANW7001459 for ; Thu, 10 Mar 2005 03:10:24 -0600 (CST) Original-Received: from kaliban.madrid.ecid.cig.mot.com.motorola.com (10.161.14.31 [10.161.14.31]) by zes06exm01.madrid.ecid.cig.mot.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) id FGJDDLSH; Thu, 10 Mar 2005 10:08:58 +0100 Original-To: emacs-devel@gnu.org 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: news.gmane.org gmane.emacs.devel:34407 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:34407 Hi, When you edit and save a writable file in a non writable dir, and you use `backup-by-copying' to nil (the default), backup-buffer fails to make a backup in the place you define with `backup-directory-alist' (because you cannot move files that are in a not writable dir), so it copies it to file "~/%backup%~". [ I know this is not very usual, but I have to edit some conf files in such directories and I got this ~/%backup%~ file around all the time ] IMHO this one-liner patch solves the problem, by detecting this situation as one of the cases where a copy should be used to backup the file. You may want to review and/or apply it. Regards juanleon --- files.el.ori Thu Mar 10 09:29:31 2005 +++ files.el Thu Mar 10 10:02:00 2005 @@ -2686,6 +2686,7 @@ backup-by-copying ;; Don't rename a suid or sgid file. (and modes (< 0 (logand modes #o6000))) + (not (file-writable-p (file-name-directory real-file-name))) (and backup-by-copying-when-linked (> (file-nlinks real-file-name) 1)) (and (or backup-by-copying-when-mismatch