unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jari Aalto <jari.aalto@cante.net>
To: Ken Brown <kbrown@cornell.edu>
Cc: 10257@debbugs.gnu.org, jari <jari.aalto@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	[thread overview]
Message-ID: <87liqf1t04.fsf@picasso.cante.net> (raw)
In-Reply-To: <4EE8178F.5040004@cornell.edu> (Ken Brown's message of "Tue, 13 Dec 2011 22:27:11 -0500")

[-- Attachment #1: Type: text/plain, Size: 1139 bytes --]

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).


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-user-variable-to-control-asking-to-a-write-prote.patch --]
[-- Type: text/x-diff, Size: 2519 bytes --]

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	other threads:[~2011-12-14  8:01 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-09 18:23 bug#10257: 23.3.1 Cygwin: network drives - file is write protected (false positive) Jari Aalto
2011-12-09 20:33 ` Ken Brown
2011-12-10  9:58   ` jaalto
2011-12-13 12:18     ` Ken Brown
2011-12-13 14:00       ` jari
2011-12-13 14:43         ` Eli Zaretskii
2011-12-13 15:12           ` Ken Brown
2011-12-13 19:27             ` Stefan Monnier
2011-12-13 20:16               ` Ken Brown
2011-12-14  2:54                 ` Stefan Monnier
2011-12-14  3:27                   ` Ken Brown
2011-12-14  8:01                     ` Jari Aalto [this message]
2011-12-14  8:35                       ` Eli Zaretskii
2011-12-14 12:24                         ` Ken Brown
2011-12-14 12:55                           ` Ken Brown
2011-12-14 13:10                             ` Eli Zaretskii
2011-12-14 14:19                               ` Ken Brown
2011-12-14 14:47                                 ` jari
2011-12-14 17:30                                 ` Eli Zaretskii
2011-12-14 17:57                                   ` Ken Brown
2011-12-15  2:43                                     ` Ken Brown
2011-12-15  2:53                                       ` Ken Brown
2011-12-15  3:19                                         ` Ken Brown
2011-12-15  4:04                                       ` Eli Zaretskii
2011-12-15 14:42                                         ` Ken Brown
2011-12-16 19:37                                           ` Ken Brown
2011-12-16 19:46                                             ` Eli Zaretskii
2011-12-16 23:15                                             ` Stefan Monnier
2011-12-17 17:08                                               ` Ken Brown
2011-12-14 14:15                             ` jari
2011-12-14 14:29                               ` Ken Brown
2011-12-14 14:43                                 ` jari
2011-12-14 17:21                                 ` Eli Zaretskii
2011-12-14 17:23             ` Richard Stallman
2011-12-13 16:26           ` jari
2011-12-13 16:52             ` Ken Brown
2011-12-13 17:48               ` jari
2011-12-13 17:48             ` Eli Zaretskii
2011-12-13 18:05               ` jari
2011-12-13 18:36                 ` Eli Zaretskii
2011-12-15 14:44           ` Jason Rumney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87liqf1t04.fsf@picasso.cante.net \
    --to=jari.aalto@cante.net \
    --cc=10257@debbugs.gnu.org \
    --cc=kbrown@cornell.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).