Subject: bug#17706: 24.4.50; locked file error in rmail-insert-inbox-text

From: Ken Olum <[email-masked]>
Date: Sat, 14 Jun 2014 08:16:39 -0400

From: Eli Zaretskii <[email-masked]>
   Date: Sat, 07 Jun 2014 11:34:39 +0300

   Maybe we should improve what Emacs does in this case by calling
   ask-user-about-lock instead of just erroring out?

Thinking about this more, I'm not sure it is such a good idea.  For one
thing, there is the possibility of races, since we aren't actually
locking the file but just checking if it is locked.  Perhaps more
importantly, if the user says to steal the file, I don't know how to
actually do so.  This is normally done by lock_file after
ask-user-about-lock returns t.   And if the user says to ignore the
lock, I don't know how to prevent this query again when the buffer
actually is modified.

So maybe it would be better to actually lock the file.  Then we'd be
using file locks as intended.  The way I'd do it is to lock the file in
rmail-get-new-mail-1 before calling rmail-insert-inbox-text and then
unlock it after saving the file with the new messages or after
discovering that there are none.

Unfortunately, there doesn't seem to be any lisp interface to lock_file,
but I guess I could set buffer-modified-p and then call lock-buffer.

What do you think?

                                Ken