Commit ad6ad164 authored by Michael Albinus's avatar Michael Albinus
Browse files

Use `auto-save-file-name-p' in tramp-*-write-region

* lisp/net/tramp.el (tramp-handle-write-region):
* lisp/net/tramp-adb.el (tramp-adb-handle-write-region):
* lisp/net/tramp-sh.el (tramp-sh-handle-write-region):
* lisp/net/tramp-smb.el (tramp-smb-handle-write-region):
* lisp/net/tramp-sshfs.el (tramp-sshfs-handle-write-region):
Use `auto-save-file-name-p'.
parent 56c9ecc7
Pipeline #11371 failed with stages
in 18 seconds
......@@ -549,14 +549,13 @@ But handle the case, if the \"test\" command is not available."
(format "File %s exists; overwrite anyway? " filename)))))
(tramp-error v 'file-already-exists filename))
(let* ((auto-saving
(string-match-p "^#.+#$" (file-name-nondirectory filename)))
file-locked
(let (file-locked
(curbuf (current-buffer))
(tmpfile (tramp-compat-make-temp-file filename)))
;; Lock file.
(when (and (not auto-saving) (file-remote-p lockname)
(when (and (not (auto-save-file-name-p (file-name-nondirectory filename)))
(file-remote-p lockname)
(not (eq (file-locked-p lockname) t)))
(setq file-locked t)
;; `lock-file' exists since Emacs 28.1.
......
......@@ -3249,9 +3249,7 @@ implementation will be used."
(format "File %s exists; overwrite anyway? " filename)))))
(tramp-error v 'file-already-exists filename))
(let ((auto-saving
(string-match-p "^#.+#$" (file-name-nondirectory filename)))
file-locked
(let (file-locked
(uid (or (tramp-compat-file-attribute-user-id
(file-attributes filename 'integer))
(tramp-get-remote-uid v 'integer)))
......@@ -3260,7 +3258,8 @@ implementation will be used."
(tramp-get-remote-gid v 'integer))))
;; Lock file.
(when (and (not auto-saving) (file-remote-p lockname)
(when (and (not (auto-save-file-name-p (file-name-nondirectory filename)))
(file-remote-p lockname)
(not (eq (file-locked-p lockname) t)))
(setq file-locked t)
;; `lock-file' exists since Emacs 28.1.
......@@ -3269,15 +3268,11 @@ implementation will be used."
(if (and (tramp-local-host-p v)
;; `file-writable-p' calls `file-expand-file-name'. We
;; cannot use `tramp-run-real-handler' therefore.
(let (file-name-handler-alist)
(and
(file-writable-p (file-name-directory localname))
(or (file-directory-p localname)
(file-writable-p localname)))))
(file-writable-p localname)))
;; Short track: if we are on the local host, we can run directly.
(write-region
start end localname append 'no-message
(and lockname (file-local-name lockname)))
(write-region start end localname append 'no-message lockname)
(let* ((modes (tramp-default-file-modes
filename (and (eq mustbenew 'excl) 'nofollow)))
......
......@@ -1589,14 +1589,13 @@ errors for shares like \"C$/\", which are common in Microsoft Windows."
(format "File %s exists; overwrite anyway? " filename)))))
(tramp-error v 'file-already-exists filename))
(let ((auto-saving
(string-match-p "^#.+#$" (file-name-nondirectory filename)))
file-locked
(let (file-locked
(curbuf (current-buffer))
(tmpfile (tramp-compat-make-temp-file filename)))
;; Lock file.
(when (and (not auto-saving) (file-remote-p lockname)
(when (and (not (auto-save-file-name-p (file-name-nondirectory filename)))
(file-remote-p lockname)
(not (eq (file-locked-p lockname) t)))
(setq file-locked t)
;; `lock-file' exists since Emacs 28.1.
......
......@@ -295,12 +295,11 @@ arguments to pass to the OPERATION."
(format "File %s exists; overwrite anyway? " filename)))))
(tramp-error v 'file-already-exists filename))
(let ((auto-saving
(string-match-p "^#.+#$" (file-name-nondirectory filename)))
file-locked)
(let (file-locked)
;; Lock file.
(when (and (not auto-saving) (file-remote-p lockname)
(when (and (not (auto-save-file-name-p (file-name-nondirectory filename)))
(file-remote-p lockname)
(not (eq (file-locked-p lockname) t)))
(setq file-locked t)
;; `lock-file' exists since Emacs 28.1.
......
......@@ -4438,9 +4438,7 @@ of."
(format "File %s exists; overwrite anyway? " filename)))))
(tramp-error v 'file-already-exists filename))
(let ((auto-saving
(string-match-p "^#.+#$" (file-name-nondirectory filename)))
file-locked
(let (file-locked
(tmpfile (tramp-compat-make-temp-file filename))
(modes (tramp-default-file-modes
filename (and (eq mustbenew 'excl) 'nofollow)))
......@@ -4452,7 +4450,8 @@ of."
(tramp-get-remote-gid v 'integer))))
;; Lock file.
(when (and (not auto-saving) (file-remote-p lockname)
(when (and (not (auto-save-file-name-p (file-name-nondirectory filename)))
(file-remote-p lockname)
(not (eq (file-locked-p lockname) t)))
(setq file-locked t)
;; `lock-file' exists since Emacs 28.1.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment