1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-12 09:28:24 +00:00

Add lock-file-mode

* doc/emacs/files.texi (Interlocking):
* doc/lispref/files.texi (File Locks):
* etc/NEWS: Add lock-file-mode.

* lisp/files.el (lock-file-name-transforms)
(remote-file-name-inhibit-locks): Move down.
(lock-file-mode): New minor mode.
This commit is contained in:
Michael Albinus 2021-07-16 18:13:28 +02:00
parent 45cdc89986
commit 553ad9c9e8
4 changed files with 51 additions and 29 deletions

View File

@ -849,6 +849,10 @@ diff-buffer-with-file} command. @xref{Comparing Files}.
You can prevent the creation of remote lock files by setting the
variable @code{remote-file-name-inhibit-locks} to @code{t}.
@cindex lock-file-mode
The minor mode @code{lock-file-mode}, called interactively, toggles
the local value of @code{create-lockfiles} in the current buffer.
@node File Shadowing
@subsection Shadowing Files
@cindex shadow files

View File

@ -826,6 +826,11 @@ You can prevent the creation of remote lock files by setting the
variable @code{remote-file-name-inhibit-locks} to @code{t}.
@end defopt
@deffn Command lock-file-mode
This command, called interactively, toggles the local value of
@code{create-lockfiles} in the current buffer.
@end deffn
@node Information about Files
@section Information about Files
@cindex file, information about

View File

@ -2191,6 +2191,22 @@ Shift while typing 'C-a', i.e. 'C-S-a', will now highlight the text.
If the 'EMACS_TEST_VERBOSE' environment variable is set, failure
summaries will include the failing condition.
** File Locks
+++
*** New user option 'lock-file-name-transforms'.
This option allows controlling where lock files are written. It uses
the same syntax as 'auto-save-file-name-transforms'.
+++
*** New user option 'remote-file-name-inhibit-locks'.
When non-nil, this option suppresses lock files for remote files.
+++
*** New minor mode 'lock-file-mode'.
This command, called interactively, toggles the local value of
'create-lockfiles' in the current buffer.
** Miscellaneous
---
@ -2209,15 +2225,6 @@ will now restore the original order.
This is like 'insert-buffer-substring', but works in the opposite
direction.
+++
*** New user option 'lock-file-name-transforms'.
This option allows controlling where lock files are written. It uses
the same syntax as 'auto-save-file-name-transforms'.
+++
*** New user option 'remote-file-name-inhibit-locks'.
When non-nil, this option suppresses lock files for remote files.
+++
*** New user option 'kill-transform-function'.
This can be used to transform (and suppress) strings from entering the

View File

@ -412,26 +412,6 @@ ignored."
:initialize 'custom-initialize-delay
:version "21.1")
(defcustom lock-file-name-transforms nil
"Transforms to apply to buffer file name before making a lock file name.
This has the same syntax as
`auto-save-file-name-transforms' (which see), but instead of
applying to auto-save file names, it's applied to lock file names.
By default, a lock file is put into the same directory as the
file it's locking, and it has the same name, but with \".#\" prepended."
:group 'files
:type '(repeat (list (regexp :tag "Regexp")
(string :tag "Replacement")
(boolean :tag "Uniquify")))
:version "28.1")
(defcustom remote-file-name-inhibit-locks nil
"Whether to use file locks for remote files."
:group 'files
:version "28.1"
:type 'boolean)
(defvar auto-save--timer nil "Timer for `auto-save-visited-mode'.")
(defcustom auto-save-visited-interval 5
@ -485,6 +465,32 @@ If `silently', don't ask the user before saving."
:type '(choice (const t) (const nil) (const silently))
:group 'abbrev)
(defcustom lock-file-name-transforms nil
"Transforms to apply to buffer file name before making a lock file name.
This has the same syntax as
`auto-save-file-name-transforms' (which see), but instead of
applying to auto-save file names, it's applied to lock file names.
By default, a lock file is put into the same directory as the
file it's locking, and it has the same name, but with \".#\" prepended."
:group 'files
:type '(repeat (list (regexp :tag "Regexp")
(string :tag "Replacement")
(boolean :tag "Uniquify")))
:initialize 'custom-initialize-delay
:version "28.1")
(defcustom remote-file-name-inhibit-locks nil
"Whether to use file locks for remote files."
:group 'files
:version "28.1"
:type 'boolean)
(define-minor-mode lock-file-mode
"Toggle file locking in the current buffer (Lock File mode)."
:version "28.1"
(setq-local create-lockfiles (and lock-file-mode t)))
(defcustom find-file-run-dired t
"Non-nil means allow `find-file' to visit directories.
To visit the directory, `find-file' runs `find-directory-functions'."