Display unlock-file warning only when file locks are enabled

* lisp/files.el (remote-file-name-inhibit-locks): Fix docstring.

* lisp/userlock.el (userlock--handle-unlock-error):
Display warning only when `create-lockfiles' is non-nil.  (Bug#62614)

* lisp/net/tramp.el (tramp-handle-unlock-file): Raise a warning
only when `create-lockfiles' is non-nil or
`remote-file-name-inhibit-locks' is nil.
This commit is contained in:
Michael Albinus 2023-04-04 09:43:09 +02:00
parent 3b48fdc912
commit b3046c6c1f
3 changed files with 14 additions and 11 deletions

View file

@ -555,7 +555,7 @@ using a transform that puts the lock files on a local file system."
:version "28.1")
(defcustom remote-file-name-inhibit-locks nil
"Whether to use file locks for remote files."
"Whether to create file locks for remote files."
:group 'files
:version "28.1"
:type 'boolean)

View file

@ -4791,10 +4791,12 @@ Do not set it manually, it is used buffer-local in `tramp-get-lock-pid'.")
(delete-file lockname)
;; Trigger the unlock error.
(signal 'file-error `("Cannot remove lock file for" ,file)))
;; `userlock--handle-unlock-error' exists since Emacs 28.1.
(error
(when create-lockfiles
(tramp-compat-funcall 'userlock--handle-unlock-error err)))))
;; `userlock--handle-unlock-error' exists since Emacs 28.1. It
;; checks for `create-lockfiles' since Emacs 30.1, we don't need
;; this chweck here, then.
(error (unless (or (not create-lockfiles)
(bound-and-true-p remote-file-name-inhibit-locks))
(tramp-compat-funcall 'userlock--handle-unlock-error err)))))
(defun tramp-handle-load (file &optional noerror nomessage nosuffix must-suffix)
"Like `load' for Tramp files."

View file

@ -206,11 +206,12 @@ file, then make the change again."))
;;;###autoload
(defun userlock--handle-unlock-error (error)
"Report an ERROR that occurred while unlocking a file."
(display-warning
'(unlock-file)
;; There is no need to explain that this is an unlock error because
;; ERROR is a `file-error' condition, which explains this.
(message "%s, ignored" (error-message-string error))
:warning))
(when create-lockfiles
(display-warning
'(unlock-file)
;; There is no need to explain that this is an unlock error because
;; ERROR is a `file-error' condition, which explains this.
(message "%s, ignored" (error-message-string error))
:warning)))
;;; userlock.el ends here