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

From: Noam Postavsky <[email-masked]>
Date: Thu, 05 Mar 2020 12:54:41 -0500

David Kastrup <[email-masked]> writes:

> Sorry for the red herring.  It was the thing that occured to me first.

No need to apologize, it was a reasonable guess.  And anyway it led to
the right answer in the end.

Eli Zaretskii <[email-masked]> writes:
>> 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.

> 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?
The comment for lock_file says:

   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?