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: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#78866: closed ([PATCH] (Finsert_file_contents): Refine commit
 d07af40d8826)
Date: Sat, 28 Jun 2025 03:15:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Fri, 27 Jun 2025 23:14:45 -0400
with message-id <jwvh600r20q.fsf-monnier+emacs <at> gnu.org>
and subject line Re: bug#78866: [PATCH] (Finsert_file_contents): Refine commit d07af40d8826
has caused the debbugs.gnu.org bug report #78866,
regarding [PATCH] (Finsert_file_contents): Refine commit d07af40d8826
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
78866: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=78866
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] (Finsert_file_contents): Refine commit d07af40d8826
Date: Sun, 22 Jun 2025 22:28:31 -0400
[Message part 3 (text/plain, inline)]
Tags: patch

As requested in bug#78777, here's a separate bug report for the
following problem:

- Start with:

      % src/emacs -Q BUGS &
      % echo foo >>BUGS

- In the Emacs session type:

      a

  Notice how Emacs correctly prompts about "changed on disk, really edit".
  Hit `C-g` so we don't actually edit the buffer.

- In the Emacs session do:

      M-: (insert-file-contents "README" nil nil nil t) RET

  Notice how Emacs just blindly changed the contents of the buffer
  without prompting about "changed on disk, really edit".

I think this last step is an error, we should be prompted just as we are
with any other buffer modification that diverges from the file's contents.

The patch below does just that,


        Stefan

[0002-Finsert_file_contents-Refine-commit-d07af40d8826.patch (text/patch, attachment)]
[Message part 5 (message/rfc822, inline)]
From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 78866-done <at> debbugs.gnu.org
Subject: Re: bug#78866: [PATCH] (Finsert_file_contents): Refine commit
 d07af40d8826
Date: Fri, 27 Jun 2025 23:14:45 -0400
>> we should additionally check that BEG==BEGV and Z==ZV:
>> 
>>     if (!NILP (visit) && BEG == BEGV && Z == ZV)
>
> To this I agree: the condition means that the previous buffer contents
> is discarded, and likewise its relation to the original file, and the
> buffer will from now on visit the new file, originally having the
> exact contents of that new file.  In that specific case, indeed
> there's no sense in any super-session warnings.

Thanks, pushed.

>> 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.
> I'd be reluctant to make such a change: who knows which package out
> there uses this unintentional feature?

Fair enough, closing,


        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.