summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2021-07-08 21:13:40 +0200
committerMichael Albinus <michael.albinus@gmx.de>2021-07-08 21:13:40 +0200
commita6a92e3ac55b4a07f3b91dffecc28a89c2b5dbf2 (patch)
treed2820313d3076143011ab5c4fbe3b42282465baf /src
parent274e71f5cc33834a08e7bd24418553198cb01f34 (diff)
downloademacs-a6a92e3ac55b4a07f3b91dffecc28a89c2b5dbf2.tar.gz
emacs-a6a92e3ac55b4a07f3b91dffecc28a89c2b5dbf2.tar.bz2
emacs-a6a92e3ac55b4a07f3b91dffecc28a89c2b5dbf2.zip
Code cleanup wrt file locks
* lisp/files.el (make-lock-file-name): Fix docstring. * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist): * lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): * lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add `make-lock-file-name'. * lisp/net/tramp.el (tramp-file-name-for-operation): Add `make-lock-file-name'. (tramp-handle-unlock-file): Call `userlock--handle-unlock-error' in case of error. * src/buffer.c (Frestore_buffer_modified_p): * src/editfns.c (Freplace_buffer_contents): * src/fileio.c (Finsert_file_contents, write_region): Call Funlock_file. * src/filelock.c (unlock_file): Rename from unlock_file_body. Remove the other declarations of unlock_file. Move file name handler check to ... (Funlock_file): ... here. Adapt argument numbers. Call unlock_file wrapped by internal_condition_case. (Flock_file): Adapt argument numbers. (unlock_all_files, Funlock_buffer, unlock_buffer): Call Funlock_file. * src/lisp.h (unlock_file): Remove.
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c2
-rw-r--r--src/editfns.c2
-rw-r--r--src/fileio.c16
-rw-r--r--src/filelock.c58
-rw-r--r--src/lisp.h1
5 files changed, 35 insertions, 44 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 565577e75ae..3cd47fede36 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1451,7 +1451,7 @@ state of the current buffer. Use with care. */)
if (!already && !NILP (flag))
lock_file (fn);
else if (already && NILP (flag))
- unlock_file (fn);
+ Funlock_file (fn);
}
}
diff --git a/src/editfns.c b/src/editfns.c
index aa0f46fea04..8ab17ebc9f9 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2137,7 +2137,7 @@ nil. */)
the file now. */
if (SAVE_MODIFF == MODIFF
&& STRINGP (BVAR (a, file_truename)))
- unlock_file (BVAR (a, file_truename));
+ Funlock_file (BVAR (a, file_truename));
}
return Qt;
diff --git a/src/fileio.c b/src/fileio.c
index c0d1a5084a0..30e6caf7ea5 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4544,7 +4544,7 @@ by calling `format-decode', which see. */)
if (inserted == 0)
{
if (we_locked_file)
- unlock_file (BVAR (current_buffer, file_truename));
+ Funlock_file (BVAR (current_buffer, file_truename));
Vdeactivate_mark = old_Vdeactivate_mark;
}
else
@@ -4706,8 +4706,8 @@ by calling `format-decode', which see. */)
if (NILP (handler))
{
if (!NILP (BVAR (current_buffer, file_truename)))
- unlock_file (BVAR (current_buffer, file_truename));
- unlock_file (filename);
+ Funlock_file (BVAR (current_buffer, file_truename));
+ Funlock_file (filename);
}
if (not_regular)
xsignal2 (Qfile_error,
@@ -5193,7 +5193,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
{
int open_errno = errno;
if (file_locked)
- unlock_file (lockname);
+ Funlock_file (lockname);
report_file_errno ("Opening output file", filename, open_errno);
}
@@ -5208,7 +5208,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
{
int lseek_errno = errno;
if (file_locked)
- unlock_file (lockname);
+ Funlock_file (lockname);
report_file_errno ("Lseek error", filename, lseek_errno);
}
}
@@ -5345,7 +5345,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
unbind_to (count, Qnil);
if (file_locked)
- unlock_file (lockname);
+ Funlock_file (lockname);
/* Do this before reporting IO error
to avoid a "file has changed on disk" warning on
@@ -5370,14 +5370,14 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
bset_filename (current_buffer, visit_file);
update_mode_lines = 14;
if (auto_saving_into_visited_file)
- unlock_file (lockname);
+ Funlock_file (lockname);
}
else if (quietly)
{
if (auto_saving_into_visited_file)
{
SAVE_MODIFF = MODIFF;
- unlock_file (lockname);
+ Funlock_file (lockname);
}
return Qnil;
diff --git a/src/filelock.c b/src/filelock.c
index 20916ace50d..9f1968f07de 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -657,6 +657,8 @@ lock_file (Lisp_Object fn)
if (will_dump_p ())
return;
+ /* If the file name has special constructs in it,
+ call the corresponding file name handler. */
Lisp_Object handler;
handler = Ffind_file_name_handler (fn, Qlock_file);
if (!NILP (handler))
@@ -705,20 +707,10 @@ lock_file (Lisp_Object fn)
}
static Lisp_Object
-unlock_file_body (Lisp_Object fn)
+unlock_file (Lisp_Object fn)
{
char *lfname;
- /* If the file name has special constructs in it,
- call the corresponding file name handler. */
- Lisp_Object handler;
- handler = Ffind_file_name_handler (fn, Qunlock_file);
- if (!NILP (handler))
- {
- call2 (handler, Qunlock_file, fn);
- return Qnil;
- }
-
Lisp_Object lock_filename = make_lock_file_name (fn);
if (NILP (lock_filename))
return Qnil;
@@ -740,26 +732,12 @@ unlock_file_handle_error (Lisp_Object err)
return Qnil;
}
-void
-unlock_file (Lisp_Object fn)
-{
- internal_condition_case_1 (unlock_file_body,
- fn,
- list1(Qfile_error),
- unlock_file_handle_error);
-}
-
#else /* MSDOS */
void
lock_file (Lisp_Object fn)
{
}
-void
-unlock_file (Lisp_Object fn)
-{
-}
-
#endif /* MSDOS */
void
@@ -773,12 +751,11 @@ unlock_all_files (void)
b = XBUFFER (buf);
if (STRINGP (BVAR (b, file_truename))
&& BUF_SAVE_MODIFF (b) < BUF_MODIFF (b))
- unlock_file (BVAR (b, file_truename));
+ Funlock_file (BVAR (b, file_truename));
}
}
-DEFUN ("lock-file", Flock_file, Slock_file,
- 0, 1, 0,
+DEFUN ("lock-file", Flock_file, Slock_file, 1, 1, 0,
doc: /* Lock FILE.
If the option `create-lockfiles' is nil, this does nothing. */)
(Lisp_Object file)
@@ -788,13 +765,28 @@ If the option `create-lockfiles' is nil, this does nothing. */)
return Qnil;
}
-DEFUN ("unlock-file", Funlock_file, Sunlock_file,
- 0, 1, 0,
+DEFUN ("unlock-file", Funlock_file, Sunlock_file, 1, 1, 0,
doc: /* Unlock FILE. */)
(Lisp_Object file)
{
+#ifndef MSDOS
CHECK_STRING (file);
- unlock_file (file);
+
+ /* If the file name has special constructs in it,
+ call the corresponding file name handler. */
+ Lisp_Object handler;
+ handler = Ffind_file_name_handler (file, Qunlock_file);
+ if (!NILP (handler))
+ {
+ call2 (handler, Qunlock_file, file);
+ return Qnil;
+ }
+
+ internal_condition_case_1 (unlock_file,
+ file,
+ list1 (Qfile_error),
+ unlock_file_handle_error);
+#endif /* MSDOS */
return Qnil;
}
@@ -829,7 +821,7 @@ error did not occur. */)
{
if (SAVE_MODIFF < MODIFF
&& STRINGP (BVAR (current_buffer, file_truename)))
- unlock_file (BVAR (current_buffer, file_truename));
+ Funlock_file (BVAR (current_buffer, file_truename));
return Qnil;
}
@@ -840,7 +832,7 @@ unlock_buffer (struct buffer *buffer)
{
if (BUF_SAVE_MODIFF (buffer) < BUF_MODIFF (buffer)
&& STRINGP (BVAR (buffer, file_truename)))
- unlock_file (BVAR (buffer, file_truename));
+ Funlock_file (BVAR (buffer, file_truename));
}
DEFUN ("file-locked-p", Ffile_locked_p, Sfile_locked_p, 1, 1, 0,
diff --git a/src/lisp.h b/src/lisp.h
index 4fb89236788..ce4b80a27ec 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4622,7 +4622,6 @@ extern void syms_of_sysdep (void);
/* Defined in filelock.c. */
extern void lock_file (Lisp_Object);
-extern void unlock_file (Lisp_Object);
extern void unlock_all_files (void);
extern void unlock_buffer (struct buffer *);
extern void syms_of_filelock (void);