When two users edit the same file at the same time, they are likely to interfere with each other. Emacs tries to prevent this situation from arising by recording a file lock when a file is being modified. Emacs can then detect the first attempt to modify a buffer visiting a file that is locked by another Emacs job, and ask the user what to do.
File locks are not completely reliable when multiple machines can share file systems. When file locks do not work, it is possible for two users to make changes simultaneously, but Emacs can still warn the user who saves second. Also, the detection of modification of a buffer visiting a file changed on disk catches some cases of simultaneous editing; see section Comparison of Modification Time.
nil
if the file filename is not
locked. It returns t
if it is locked by this Emacs process, and
it returns the name of the user who has locked it if it is locked by
some other job.
(file-locked-p "foo") => nil
t
says to grab the lock on the file. Then
this user may edit the file and other-user loses the lock.
nil
says to ignore the lock and let this
user edit the file anyway.
file-locked
error, in which
case the change that the user was about to make does not take place.
The error message for this error looks like this:
error--> File is locked: file other-userwhere
file
is the name of the file and other-user is the
name of the user who has locked the file.
If you wish, you can replace the ask-user-about-lock
function
with your own version that makes the decision in another way. The code
for its usual definition is in `userlock.el'.
Go to the first, previous, next, last section, table of contents.