bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#10257: 23.3.1 Cygwin: network drives - file is write protected (fals


From: Jari Aalto
Subject: bug#10257: 23.3.1 Cygwin: network drives - file is write protected (false positive)
Date: Wed, 14 Dec 2011 10:01:47 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.3 (gnu/linux)

2011-12-14 05:27 Ken Brown <kbrown@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@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).

>From 5e1873b417fd5bc79a05339cb9d1e1aacb57164a Mon Sep 17 00:00:00 2001
From: Jari Aalto <jari.aalto@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@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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]