Subject: Re: bug#15381: 24.3; NTEmacs write-region behaviour with MUSTBENEW set to 'excl
From: Eli Zaretskii <[email-masked]>
To: Phil Sainty <[email-masked]>
Cc: [email-masked]
Date: Sun, 15 Sep 2013 12:46:32 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> Date: Sun, 15 Sep 2013 20:21:37 +1200
> From: Phil Sainty <[email-masked]>
> 
> I'm using write-region with the MUSTBENEW argument set to 'excl
> to prohibit writing to an existing file. This works as advertised
> on Ubuntu, but I happened to try the code under Windows and found
> that the write was not prevented.
> 
> I further observed that, in this circumstance, the written
> content only overwrites the start of the target file (leaving
> the remainder), rather than replacing the whole file. This
> appears to be the same behaviour as setting the APPEND argument
> to zero.
> 
> Setting MUSTBENEW to t works as expected.
> 
> I'm using the following to test:
> 
> M-: (write-region (region-beginning) (region-end) "~/somefile" nil nil 
> nil 'excl) RET

This is a known problem on Windows in all versions of Emacs released
until now.  The problem is already fixed in the development code.

If you can build your own Emacs, I can show you the change that is
required to fix the bug.

Thanks.