GNU bug report logs - #78866
[PATCH] (Finsert_file_contents): Refine commit d07af40d8826

Previous Next

Package: emacs;

Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>

Date: Mon, 23 Jun 2025 02:30:02 UTC

Severity: normal

Tags: patch

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 78866 <at> debbugs.gnu.org
Subject: bug#78866: [PATCH] (Finsert_file_contents): Refine commit d07af40d8826
Date: Thu, 26 Jun 2025 12:39:14 -0400
>> > I agree that we should prompt, but I don't understand the logic behind
>> > the proposed solution.  Why is it OK not to prompt when VISIT is
>> > non-nil?  It is true that in that case we will be reading from
>> > FILENAME, but the contents after the insertion will not necessarily be
>> > identical to FILENAME, because not necessarily the entire contents of
>> > the buffer is erased.
>> If VISIT is non-nil, then REPLACE is also non-nil (or irrelevant
>> because the buffer is empty):
>> 
>>     if (!NILP (visit))
>>       {
>>         if (!NILP (beg) || !NILP (end))
>>           error ("Attempt to visit less than an entire file");
>>         if (BEG < Z && NILP (replace))
>>           error ("Cannot do file visiting in a non-empty buffer");
>>       }
>
> Sure, but REPLACE replaces only the accessible portion of the buffert,
> not all of it.

Then we should tighten the check even further.  Instead of just adding

    if (!NILP (visit))

we should additionally check that BEG==BEGV and Z==ZV:

    if (!NILP (visit) && BEG == BEGV && Z == ZV)

Tho, maybe the `BEG == BEGV && Z == ZV` check should be performed in the
above quoted sanity check, because I think using a non-nil VISIT within
a narrowed buffer goes against the intention of VISIT.


        Stefan





This bug report was last modified 1 day ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.