Subject: 29.3; When doing a backup, the file is missing during interactive questions

From: Vincent Lefevre <[email-masked]>
Date: Mon, 20 May 2024 03:07:48 +0200

When doing a backup, GNU Emacs renames the file (according to strace).
Under some conditions, the file can be lost.

I noticed that due to a bug in the combination between Emacs and gpg,
where the "save" operation cannot be completed.

To reproduce with "emacs -Q", do for a file that is not under version
control (otherwise --eval="(setq vc-make-backup-files t)" is needed):

1. emacs -Q file.gpg
2. Modify the file.
3. Save with C-x C-s

At this point, gpg gets interactive, with a question

  Untrusted key [...].  Use anyway? (y or n)

and one can see that the file "file.gpg" has been renamed to
"file.gpg~".

And it may happen that the save operation will never be completed,
e.g. because of a bug like

  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1071372

(where gpg never terminates) or because Emacs may be killed before
the user could complete the save operation.

In short, the file may have silently disappeared. There is a backup,
but the backups may be cleaned up before the user realizes the issue.

Note: I put the backups in a specific directory with

(defun find-backup-file-name (fn)
       (list (concat "~/.poub/" (file-name-nondirectory fn) "~")))

but I look at it only when I know I've done something wrong or if
I get an error message about the save operation. Having a missing
file during interactive questions is bad.

Note: I'm using Debian's package emacs-gtk 1:29.3+1-3.

-- 
Vincent Lefèvre <[email-masked]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)