* 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.
(defun make-lock-file-name (filename)
"Make a lock file name for FILENAME.
-By default, this just prepends \".*\" to the non-directory part
+By default, this just prepends \".#\" to the non-directory part
of FILENAME, but the transforms in `lock-file-name-transforms'
are done first."
(let ((handler (find-file-name-handler filename 'make-lock-file-name)))
(make-auto-save-file-name . tramp-handle-make-auto-save-file-name)
(make-directory . tramp-adb-handle-make-directory)
(make-directory-internal . ignore)
+ ;; `make-lock-file-name' performed by default handler.
(make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
(make-process . tramp-adb-handle-make-process)
(make-symbolic-link . tramp-handle-make-symbolic-link)
(make-auto-save-file-name . ignore)
(make-directory . tramp-archive-handle-not-implemented)
(make-directory-internal . tramp-archive-handle-not-implemented)
+ (make-lock-file-name . ignore)
(make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
(make-process . ignore)
(make-symbolic-link . tramp-archive-handle-not-implemented)
(make-auto-save-file-name . tramp-handle-make-auto-save-file-name)
(make-directory . tramp-crypt-handle-make-directory)
(make-directory-internal . ignore)
+ ;; `make-lock-file-name' performed by default handler.
(make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
(make-process . ignore)
(make-symbolic-link . tramp-handle-make-symbolic-link)
(make-auto-save-file-name . tramp-handle-make-auto-save-file-name)
(make-directory . tramp-gvfs-handle-make-directory)
(make-directory-internal . ignore)
+ ;; `make-lock-file-name' performed by default handler.
(make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
(make-process . ignore)
(make-symbolic-link . tramp-handle-make-symbolic-link)
(make-auto-save-file-name . tramp-handle-make-auto-save-file-name)
(make-directory . tramp-fuse-handle-make-directory)
(make-directory-internal . ignore)
+ ;; `make-lock-file-name' performed by default handler.
(make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
(make-process . ignore)
(make-symbolic-link . tramp-handle-make-symbolic-link)
(make-auto-save-file-name . tramp-handle-make-auto-save-file-name)
(make-directory . tramp-sh-handle-make-directory)
;; `make-directory-internal' performed by default handler.
+ ;; `make-lock-file-name' performed by default handler.
(make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
(make-process . tramp-sh-handle-make-process)
(make-symbolic-link . tramp-sh-handle-make-symbolic-link)
(make-auto-save-file-name . tramp-handle-make-auto-save-file-name)
(make-directory . tramp-smb-handle-make-directory)
(make-directory-internal . tramp-smb-handle-make-directory-internal)
+ ;; `make-lock-file-name' performed by default handler.
(make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
(make-process . ignore)
(make-symbolic-link . tramp-smb-handle-make-symbolic-link)
(make-auto-save-file-name . tramp-handle-make-auto-save-file-name)
(make-directory . tramp-fuse-handle-make-directory)
(make-directory-internal . ignore)
+ ;; `make-lock-file-name' performed by default handler.
(make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
(make-process . tramp-handle-make-process)
(make-symbolic-link . tramp-handle-make-symbolic-link)
(make-auto-save-file-name . tramp-handle-make-auto-save-file-name)
(make-directory . tramp-sudoedit-handle-make-directory)
(make-directory-internal . ignore)
+ ;; `make-lock-file-name' performed by default handler.
(make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
(make-process . ignore)
(make-symbolic-link . tramp-sudoedit-handle-make-symbolic-link)
;; Emacs 27+ only.
file-system-info
;; Emacs 28+ only.
- file-locked-p lock-file unlock-file
+ file-locked-p lock-file make-lock-file-name unlock-file
;; Tramp internal magic file name function.
tramp-set-file-uid-gid))
(if (file-name-absolute-p (nth 0 args))
(defun tramp-handle-unlock-file (file)
"Like `unlock-file' for Tramp files."
- (ignore-errors
- (delete-file (tramp-compat-make-lock-file-name file))))
+ (condition-case err
+ (delete-file (tramp-compat-make-lock-file-name file))
+ (error (userlock--handle-unlock-error err))))
(defun tramp-handle-load (file &optional noerror nomessage nosuffix must-suffix)
"Like `load' for Tramp files."
(display-warning
'(unlock-file)
;; There is no need to explain that this is an unlock error because
- ;; ERR is a `file-error' condition, which explains this.
+ ;; ERROR is a `file-error' condition, which explains this.
(message "%s, ignored" (error-message-string error))
:warning))
if (!already && !NILP (flag))
lock_file (fn);
else if (already && NILP (flag))
- unlock_file (fn);
+ Funlock_file (fn);
}
}
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;
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
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,
{
int open_errno = errno;
if (file_locked)
- unlock_file (lockname);
+ Funlock_file (lockname);
report_file_errno ("Opening output file", filename, open_errno);
}
{
int lseek_errno = errno;
if (file_locked)
- unlock_file (lockname);
+ Funlock_file (lockname);
report_file_errno ("Lseek error", filename, lseek_errno);
}
}
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
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;
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))
}
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;
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
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));
}
}
\f
-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)
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;
}
{
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;
}
{
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,
/* 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);