Subject: bug#13522: 24.2; save-buffer removes edited file under some conditions

From: Eli Zaretskii <[email-masked]>
Date: Mon, 14 Mar 2022 15:37:43 +0200

> From: Lars Ingebrigtsen <[email-masked]>
> Date: Mon, 14 Mar 2022 12:21:33 +0100
> Cc: [email-masked]
> 
> Vincent Lefevre <[email-masked]> writes:
> 
> > 1. Create a file with: printf "\x80" > file
> > 2. Open the file under X Window with: emacs -Q file
> > 3. Modify the file e.g. by adding a space.
> > 4. Type C-x C-s
> >    At this point, Emacs asks the user to select a coding system.
> > 5. Type C-c in the terminal to kill Emacs.
> >
> > The result is that the file "file" is no longer there!
> 
> (I'm going through old bug reports that unfortunately weren't resolved
> at the time.)
> 
> This problem is still present in Emacs 29 -- the file is moved to the
> backup file before doing the prompt.

Is it "C-c to kill Emacs" as in "terminate Emacs with a fatal signal",
or is it "C-x C-c" as in "exit Emacs in an orderly fashion"?

If the former, then in general killing a program when it is in the
middle of writing files isn't guaranteed to preserve those files.