unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org>
To: Emacs developers <emacs-devel@gnu.org>
Subject: Re: write-region bug ?
Date: Mon, 6 Jan 2020 01:42:35 +0900	[thread overview]
Message-ID: <046646BD-7C4A-4D42-93F0-9B45980DD9BC@traduction-libre.org> (raw)
In-Reply-To: <83k165gbl5.fsf@gnu.org>



> On Jan 6, 2020, at 0:35, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Stefan Monnier <monnier@iro.umontreal.ca>
>> Cc: schwab@linux-m68k.org,  jean.christophe.helary@traduction-libre.org,
>>  emacs-devel@gnu.org
>> Date: Sat, 04 Jan 2020 23:54:56 -0500
>> 
>>> I don't think it's up to us to second-guess the caller, whether this
>>> is an accident or not.  I can envision legitimate use cases where this
>>> can be useful.
>> 
>> I can entertain the idea that some package out there somehow calls
>> write-region with a non-nil `visit` and a string as `start`, but I'm
>> hard pressed to imagine a case where this is useful.
>> What kind of scenario do you have in mind?
> 
> I don't think we must imagine a specific scenario to justify
> NON-removal of an old feature, just because someone became confused by
> the doc string.

:) I'm certainly not asking a removing of that feature. But the settings that I have for the function create a behavior that's weird.

>  But since you asked...
> 
>  (write-region 1 1024 "foo")
>  (write-region "\nEnd-of-foo\n." nil "foo" t t)

>> (write-region "stuff" nil "path/to/my/file/test.txt" nil t nil t).

With APPEND set to t, that makes sense, I guess (I tried the code you wrote and I don't see why you need to have VISIT set to t).

But when APPEND is set to nil, then, as in my case, the file first gets the string and then the string is *overwritten* by the contents of the buffer that contains the write-region. Also, there is no indication whatsoever that this is happening. I only know about that when I try to save the file and emacs tells me that the file has been changed externally.

Now, I am no insisting that my t value for VISIT is correct, and I don't know where I got the idea of setting it to t. But the fact is that I don't see much value in sending a string to a file and right after it having the file overwritten with the whole buffer where the write-region command was.


Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune





  reply	other threads:[~2020-01-05 16:42 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-02 16:54 write-region bug ? Jean-Christophe Helary
2020-01-02 17:08 ` Andreas Schwab
2020-01-02 17:22   ` Jean-Christophe Helary
2020-01-02 17:25   ` Eli Zaretskii
2020-01-02 17:35     ` Jean-Christophe Helary
2020-01-04 19:58     ` Stefan Monnier
2020-01-04 20:19       ` Eli Zaretskii
2020-01-04 22:58         ` Stefan Monnier
2020-01-05  2:01           ` Jean-Christophe Helary
2020-01-05  3:33             ` Eli Zaretskii
2020-01-05  5:14               ` Jean-Christophe Helary
2020-01-05 15:20                 ` Eli Zaretskii
2020-01-05  3:37           ` Eli Zaretskii
2020-01-05  4:54             ` Stefan Monnier
2020-01-05 15:35               ` Eli Zaretskii
2020-01-05 16:42                 ` Jean-Christophe Helary [this message]
2020-01-06  3:37                   ` Eli Zaretskii
2020-01-06  3:50                     ` Jean-Christophe Helary
2020-01-06  5:29                       ` Eli Zaretskii
2020-01-06  5:58                         ` Jean-Christophe Helary
2020-01-08 15:27                           ` Jean-Christophe Helary
2020-01-08 16:05                             ` Eli Zaretskii
2020-01-09  0:04                               ` Jean-Christophe Helary
2020-01-09  0:43                                 ` Noam Postavsky
2020-01-09 12:30                             ` Jean-Christophe Helary
2020-01-09 14:07                               ` Eli Zaretskii
2020-01-09 14:39                                 ` Jean-Christophe Helary
2020-01-09 17:03                                   ` Eli Zaretskii
2020-01-09 23:21                                     ` Jean-Christophe Helary
2020-01-05 17:37                 ` Stefan Monnier
2020-01-05 18:26                   ` Eli Zaretskii
2020-01-05 19:27                     ` Stefan Monnier

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=046646BD-7C4A-4D42-93F0-9B45980DD9BC@traduction-libre.org \
    --to=jean.christophe.helary@traduction-libre.org \
    --cc=emacs-devel@gnu.org \
    /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).