Subject: bug#18336: 24.4.50; When editing externally changed file, Emacs asks too many questions

From: Eli Zaretskii <[email-masked]>
Date: Thu, 05 Mar 2020 18:02:52 +0200

> From: Noam Postavsky <[email-masked]>
> Cc: [email-masked],  [email-masked],  [email-masked]
> Date: Thu, 05 Mar 2020 09:13:32 -0500
> 
> Ah, looks like the noatime thing is just a coincidence.  What happens in
> the ~/tmp case is that when lock_file is called from write_region, the
> file doesn't exist, so the extra "changed on disk" question doesn't get
> asked.  The reason the file doesn't exist, is because it was moved to
> the backup name, in backup-buffer.  Files under /tmp/ are not backed up
> by default, so in that case the file still exists and there is an extra
> query.
> 
>     lock_file (Lisp_Object fn)
>     {
>       [...]
>         if (!NILP (subject_buf)
>         && NILP (Fverify_visited_file_modtime (subject_buf))
>         && !NILP (Ffile_exists_p (fn)))
>           call1 (intern ("userlock--ask-user-about-supersession-threat"), fn);
> 
>     (defun backup-buffer ()
>       [...]
>                   (rename-file real-file-name backupname t)

Thanks.  Any suggestions for how to fix this?  A new argument to
lock_file, perhaps?  Or maybe some additional check in
userlock--ask-user-about-supersession-threat to recognize the special
situation where we are saving a file?