Subject: Re: 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 21:31:20 +0200

> From: Noam Postavsky <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>,  [email-masked],  [email-masked]
> Date: Thu, 05 Mar 2020 12:54:41 -0500
> 
> > 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?
> 
> I'm not sure.  Why exactly are we calling lock_file from write_region?

Because write-region can be called from an unmodified buffer, I
suppose, and from a buffer whose buffer-file-name is not the same as
the file being written to.

>    Do not (normally) call this for a buffer already modified,
>    as either the file is already locked, or the user has already
>    decided to go ahead without locking.
> 
> It seems we are doing exactly this, so I guess that makes
> save-buffer/write-region an "abnormal" situation?

Evidently, when we disabled backups in /tmp, we missed the fact that
lock_file called from write-region will be affected.  When backups are
not disabled, this works correctly.