GNU bug report logs - #10257
23.3.1 Cygwin: network drives - file is write protected (false positive)

Previous Next

Package: emacs;

Reported by: Jari Aalto <jari.aalto <at> cante.net>

Date: Fri, 9 Dec 2011 18:25:02 UTC

Severity: normal

Found in version 23.3+1-4

Fixed in version 24.0.93

Done: Ken Brown <kbrown <at> cornell.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Jari Aalto <jari.aalto <at> cante.net>
To: Ken Brown <kbrown <at> cornell.edu>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 10257 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>, jari <jari.aalto <at> cante.net>
Subject: bug#10257: 23.3.1 Cygwin: network drives - file is write protected (false positive)
Date: Wed, 14 Dec 2011 10:01:47 +0200
[Message part 1 (text/plain, inline)]
2011-12-14 05:27 Ken Brown <kbrown <at> cornell.edu>:
| On 12/13/2011 9:54 PM, Stefan Monnier wrote:
| >> The code I'm talking about is near the beginning of the definition of
| >> basic-save-buffer-2' in files.el:
| >
| > I'm not sure what was the intention, but I know that this code is
| > triggered in cases such as:
|   [snip]
|
| (... and) saving to a file that is in fact writable, for which
| file-writable-p gives the wrong answer.
| 
| > This said, the code you quote should never prevent you from saving
| > a file, it should only ask for confirmation (i.e. it might be annoying
| > but it shouldn't prevent you from getting your work done).

For occasional confirmation, this is acceptable. But in this case every
single save is prompted while I know I have a write access. The protective
prompting turned into nightmare.

I'm proposing following,
Jari

2011-12-14  Jari Aalto  <jari.aalto <at> cante.net>

        * files.el (basic-save-buffer-2): Add
        `save-buffer-read-only-confirm-flag' to control asking to a
        write-protected file.
        (save-buffer-read-only-confirm-flag): New user variable
        (bug#10257).

[0001-Add-user-variable-to-control-asking-to-a-write-prote.patch (text/x-diff, inline)]
From 5e1873b417fd5bc79a05339cb9d1e1aacb57164a Mon Sep 17 00:00:00 2001
From: Jari Aalto <jari.aalto <at> cante.net>
Date: Wed, 14 Dec 2011 10:00:38 +0200
Subject: [PATCH] Add user variable to control asking to a write-protected
 file.
Organization: Private
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

files.el (basic-save-buffer-2): Add `save-buffer-read-only-confirm-flag'
(save-buffer-read-only-confirm-flag): New user variable (bug#10257).

Signed-off-by: Jari Aalto <jari.aalto <at> cante.net>
---
 lisp/files.el |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 40b6e7d..52c11b7 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4445,9 +4445,17 @@ Before and after saving the buffer, this function runs
       (setq buffer-file-coding-system-explicit
 	    (cons last-coding-system-used nil)))))
 
+;; See 2011-12-09 Emacs Bug#10257 for details
+(defvar save-buffer-read-only-confirm-flag t
+  "*If non-nil, do not ask writable confiramtion in `basic-save-buffer-2'.
+Useful e.g. under Cygwin where the returned read-only status of
+a file may not be accurate over Windows mapped network drives.")
+
 ;; This returns a value (MODES SELINUXCONTEXT BACKUPNAME), like backup-buffer.
 (defun basic-save-buffer-2 ()
   (let (tempsetmodes setmodes)
+    ;; Note: the file-writable-p checks
+    ;; UID, GID which are not necessarily correct e.g. under Cygwin.
     (if (not (file-writable-p buffer-file-name))
 	(let ((dir (file-name-directory buffer-file-name)))
 	  (if (not (file-directory-p dir))
@@ -4456,13 +4464,14 @@ Before and after saving the buffer, this function runs
 		(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"))))))
+	      (if save-buffer-read-only-confirm-flag
+		  (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")))))))
     (or buffer-backed-up
 	(setq setmodes (backup-buffer)))
     (let* ((dir (file-name-directory buffer-file-name))
-- 
1.7.7.3


This bug report was last modified 13 years and 238 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.