GNU bug report logs -
#78866
[PATCH] (Finsert_file_contents): Refine commit d07af40d8826
Previous Next
Full log
View this message in rfc822 format
> Cc: <monnier <at> iro.umontreal.ca>
> Date: Sun, 22 Jun 2025 22:28:31 -0400
> From: Stefan Monnier via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>
> - 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,
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. The case where the entire buffer is erased and
its contents replaced by that of FILENAME, in which case the prompt
indeed makes no sense, is a special case, not the general case.
Also note that the prompt, if we issue it here, will not be about
FILENAME, it will be about the file visited by the buffer, which at
this point is still the original buffer-file-name. In your example
above, it's "BUGS", not "README". Which is wrong when VISIT is
non-nil, but the correct solution is not just disable the prompt, it's
to issue the prompt about a different file, no?
So I'd prefer to fix this more thoroughly and correctly.
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.