[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Proposed patch: allow user to disable lockfile creation

From: Dave Abrahams
Subject: Proposed patch: allow user to disable lockfile creation
Date: Tue, 26 Jul 2011 22:42:39 -0400


Those symlinks that emacs creates to help avoid collisions between users
editing simultaneously cause me lots of pain and no gain, so I propose
the enclosed patch that allows me to disable the feature.

I hereby place these changes in the public domain.

>From e79326938de1c2567ac2ab1cac2fea91482a59e7 Mon Sep 17 00:00:00 2001
From: Dave Abrahams <address@hidden>
Date: Tue, 26 Jul 2011 22:32:13 -0400
Subject: [PATCH] Add a customizable option that disables lockfile creation

 ChangeLog            |    4 ++++
 doc/emacs/files.texi |    9 +++++----
 lisp/cus-start.el    |    1 +
 src/filelock.c       |    8 ++++++++
 4 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e4a4754..87a3072 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-07-26  Dave Abrahams  <address@hidden>
+       * src/file_lock.c, lisp/cus-start.el: Add option to disable lockfile 
 2011-06-19  Paul Eggert  <address@hidden>
        * lib/unistd.in.h, m4/getloadavg.m4: Merge from gnulib.
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index 793a11e..3f94741 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -761,16 +761,17 @@ to change the file, and issues an immediate warning.  On 
all systems,
 Emacs checks when you save the file, and warns if you are about to
 overwrite another user's changes.  You can prevent loss of the other
 user's work by taking the proper corrective action instead of saving the
 @findex ask-user-about-lock
 @cindex locking files
   When you make the first modification in an Emacs buffer that is
 visiting a file, Emacs records that the file is @dfn{locked} by you.
 (It does this by creating a specially-named symbolic link in the same
-directory.)  Emacs removes the lock when you save the changes.  The
-idea is that the file is locked whenever an Emacs buffer visiting it
-has unsaved changes.
+directory.  You can disable this behavior by setting the variable
address@hidden to @code{nil}).  Emacs removes the lock when
+you save the changes.  The idea is that the file is locked whenever an
+Emacs buffer visiting it has unsaved changes.
 @cindex collision
   If you begin to modify the buffer while the visited file is locked by
diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index 389716b..1d8c908 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -183,6 +183,7 @@ Leaving \"Default\" unchecked is equivalent with specifying 
a default of
              (delete-by-moving-to-trash auto-save boolean "23.1")
             (auto-save-visited-file-name auto-save boolean)
             ;; filelock.c
+             (create-lockfiles files boolean)
              ;; Darwin section added 24.1, does not seem worth :version bump.
              files directory nil
diff --git a/src/filelock.c b/src/filelock.c
index 13b27c7..8078a74 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -541,6 +541,10 @@ lock_file (Lisp_Object fn)
   lock_info_type lock_info;
   struct gcpro gcpro1;
+  /* Don't do locking if the user has opted out.  */
+  if (! Vcreate_lockfiles)
+    return;
   /* Don't do locking while dumping Emacs.
      Uncompressing wtmp files uses call-process, which does not work
      in an uninitialized Emacs.  */
@@ -709,6 +713,10 @@ syms_of_filelock (void)
               doc: /* The directory for writing temporary files.  */);
   Vtemporary_file_directory = Qnil;
+  DEFVAR_BOOL ("create-lockfiles", Vcreate_lockfiles,
+              doc: /* Non-nil means use lockfiles to avoid editing collisions. 
+  Vcreate_lockfiles = 1;
   defsubr (&Sunlock_buffer);
   defsubr (&Slock_buffer);

Dave Abrahams
BoostPro Computing

reply via email to

[Prev in Thread] Current Thread [Next in Thread]