From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ken Brown Newsgroups: gmane.emacs.bugs Subject: bug#10257: 23.3.1 Cygwin: network drives - file is write protected (false positive) Date: Tue, 13 Dec 2011 15:16:41 -0500 Message-ID: <4EE7B2A9.6060308@cornell.edu> References: <87aa71mwng.fsf@picasso.cante.net> <4EE270AA.2080702@cornell.edu> <20111210095858.GA19881@cante.cante.net> <4EE742B0.1080703@cornell.edu> <20111213140042.GA22678@picasso.cante.net> <4EE76B6E.7070904@cornell.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1323807471 4466 80.91.229.12 (13 Dec 2011 20:17:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 13 Dec 2011 20:17:51 +0000 (UTC) Cc: 10257@debbugs.gnu.org, jari To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 13 21:17:47 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RaYnK-0006UU-Qc for geb-bug-gnu-emacs@m.gmane.org; Tue, 13 Dec 2011 21:17:47 +0100 Original-Received: from localhost ([::1]:37117 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaYnK-000425-Cs for geb-bug-gnu-emacs@m.gmane.org; Tue, 13 Dec 2011 15:17:46 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:35165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaYnI-00041x-He for bug-gnu-emacs@gnu.org; Tue, 13 Dec 2011 15:17:45 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RaYnH-0003Dd-BD for bug-gnu-emacs@gnu.org; Tue, 13 Dec 2011 15:17:44 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36081) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaYnH-0003DZ-8L for bug-gnu-emacs@gnu.org; Tue, 13 Dec 2011 15:17:43 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RaYoY-0004dk-E1 for bug-gnu-emacs@gnu.org; Tue, 13 Dec 2011 15:19:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ken Brown Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 13 Dec 2011 20:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10257 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 10257-submit@debbugs.gnu.org id=B10257.132380748717774 (code B ref 10257); Tue, 13 Dec 2011 20:19:02 +0000 Original-Received: (at 10257) by debbugs.gnu.org; 13 Dec 2011 20:18:07 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RaYne-0004cd-Eo for submit@debbugs.gnu.org; Tue, 13 Dec 2011 15:18:06 -0500 Original-Received: from granite1.mail.cornell.edu ([128.253.83.141] helo=authusersmtp.mail.cornell.edu) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RaYna-0004cT-RL for 10257@debbugs.gnu.org; Tue, 13 Dec 2011 15:18:04 -0500 Original-Received: from [128.84.234.240] (dhcp240.math.cornell.edu [128.84.234.240]) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.14.4/8.12.10) with ESMTP id pBDKGfq8006826 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 13 Dec 2011 15:16:41 -0500 (EST) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Tue, 13 Dec 2011 15:19:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:54931 Archived-At: On 12/13/2011 2:27 PM, Stefan Monnier wrote: >> I have a question about the emacs side of this. I wonder what the rationale >> is for testing writability before trying to save the file, and then asking >> the user for confirmation in case the (unreliable) test for writability >> fails (*). > > Can you point us to the piece of code about which you're talking? > Ideally, show us a sample pseudo patch (even better if it compiles, even > better if it works) showing the kind of change you have in mind. The code I'm talking about is near the beginning of the definition of `basic-save-buffer-2' in files.el: (if (not (file-writable-p buffer-file-name)) (let ((dir (file-name-directory buffer-file-name))) (if (not (file-directory-p dir)) (if (file-exists-p dir) (error "%s is not a directory" dir) (error "%s: no such directory" dir)) (if (not (file-exists-p buffer-file-name)) (error "Directory %s write-protected" dir) (if (yes-or-no-p (format "File %s is write-protected; try to save anyway? " (file-name-nondirectory buffer-file-name))) (setq tempsetmodes t) (error "Attempt to save to a file which you aren't allowed to write")))))) I'm not (yet) proposing a change. I'm simply asking what the rationale is for calling `yes-or-no-p' and making the user confirm that s/he wants to try to save the file. I don't see that any harm would come from just trying to do what the user asked for, without making him/her ask a second time. If the file really is write-protected, there will be an error. If you agree, then I guess I would propose the following patch (not yet tested): === modified file 'lisp/files.el' --- lisp/files.el 2011-12-04 08:02:42 +0000 +++ lisp/files.el 2011-12-13 20:08:55 +0000 @@ -4456,13 +4456,7 @@ (error "%s: no such directory" dir)) (if (not (file-exists-p buffer-file-name)) (error "Directory %s write-protected" dir) - (if (yes-or-no-p - (format - "File %s is write-protected; try to save anyway? " - (file-name-nondirectory - buffer-file-name))) - (setq tempsetmodes t) - (error "Attempt to save to a file which you aren't allowed to write")))))) + (setq tempsetmodes t))))) (or buffer-backed-up (setq setmodes (backup-buffer))) (let* ((dir (file-name-directory buffer-file-name)) Ken