From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jari Aalto Newsgroups: gmane.emacs.bugs 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-ID: <87liqf1t04.fsf@picasso.cante.net> 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> <4EE7B2A9.6060308@cornell.edu> <4EE8178F.5040004@cornell.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1323849775 20139 80.91.229.12 (14 Dec 2011 08:02:55 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 14 Dec 2011 08:02:55 +0000 (UTC) Cc: 10257@debbugs.gnu.org, jari To: Ken Brown Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 14 09:02:50 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 1Rajne-00037H-C4 for geb-bug-gnu-emacs@m.gmane.org; Wed, 14 Dec 2011 09:02:50 +0100 Original-Received: from localhost ([::1]:57255 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rajnd-0001he-Pf for geb-bug-gnu-emacs@m.gmane.org; Wed, 14 Dec 2011 03:02:49 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:51688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RajnV-0001hJ-CW for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2011 03:02:47 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RajnU-0006p2-7i for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2011 03:02:41 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36530) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RajnU-0006ox-64 for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2011 03:02:40 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Rajon-0003t3-WE for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2011 03:04:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jari Aalto Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 14 Dec 2011 08:04:01 +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.132384980314894 (code B ref 10257); Wed, 14 Dec 2011 08:04:01 +0000 Original-Received: (at 10257) by debbugs.gnu.org; 14 Dec 2011 08:03:23 +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 1RajoA-0003sB-G1 for submit@debbugs.gnu.org; Wed, 14 Dec 2011 03:03:22 -0500 Original-Received: from emh07.mail.saunalahti.fi ([62.142.5.117]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rajo5-0003s1-Vh for 10257@debbugs.gnu.org; Wed, 14 Dec 2011 03:03:20 -0500 Original-Received: from saunalahti-vams (vs3-10.mail.saunalahti.fi [62.142.5.94]) by emh07-2.mail.saunalahti.fi (Postfix) with SMTP id 2A08718D46B; Wed, 14 Dec 2011 10:01:54 +0200 (EET) Original-Received: from emh03.mail.saunalahti.fi ([62.142.5.109]) by vs3-10.mail.saunalahti.fi ([62.142.5.94]) with SMTP (gateway) id A07BF425393; Wed, 14 Dec 2011 10:01:54 +0200 Original-Received: from picasso.cante.net (a91-155-176-245.elisa-laajakaista.fi [91.155.176.245]) by emh03.mail.saunalahti.fi (Postfix) with ESMTP id 72FD4158A68; Wed, 14 Dec 2011 10:01:47 +0200 (EET) Original-Received: from jaalto by picasso.cante.net with local (Exim 4.77) (envelope-from ) id 1Rajmd-00019V-H0; Wed, 14 Dec 2011 10:01:47 +0200 Mail-Copies-To: poster In-Reply-To: <4EE8178F.5040004@cornell.edu> (Ken Brown's message of "Tue, 13 Dec 2011 22:27:11 -0500") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.3 (gnu/linux) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: jari.aalto@cante.net X-SA-Exim-Scanned: No (on picasso.cante.net); SAEximRunCond expanded to false X-Antivirus: VAMS X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Wed, 14 Dec 2011 03:04:01 -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:54937 Archived-At: --=-=-= Content-Type: text/plain 2011-12-14 05:27 Ken Brown : | 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 * 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). --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-user-variable-to-control-asking-to-a-write-prote.patch >From 5e1873b417fd5bc79a05339cb9d1e1aacb57164a Mon Sep 17 00:00:00 2001 From: Jari Aalto 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 --- 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 --=-=-=--