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: Ken Brown
Subject: bug#10257: 23.3.1 Cygwin: network drives - file is write protected (false positive)
Date: Tue, 13 Dec 2011 15:16:41 -0500
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0

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





reply via email to

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