]> git.eshelyaron.com Git - emacs.git/commitdiff
Use `auto-save-file-name-p' in tramp-*-write-region
authorMichael Albinus <michael.albinus@gmx.de>
Sun, 11 Jul 2021 15:41:33 +0000 (17:41 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Sun, 11 Jul 2021 15:41:33 +0000 (17:41 +0200)
* 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'.

lisp/net/tramp-adb.el
lisp/net/tramp-sh.el
lisp/net/tramp-smb.el
lisp/net/tramp-sshfs.el
lisp/net/tramp.el

index 788548badec147a9f367dfaf96f428ef9a7b2c8e..63fd5eb06a3ff39cb917b75aa6b7161df3d11b3e 100644 (file)
@@ -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
-          (curbuf (current-buffer))
-          (tmpfile (tramp-compat-make-temp-file filename)))
+    (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.
index 404e9aff7a26617b3fc332ed7dc31823d0c75b0c..e5929bd366a623150e9590e3abd61603e0962060 100644 (file)
@@ -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 (file-name-directory localname))
+              (or (file-directory-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)))
index 87f62391e342d27903524bcb651467b84e4bae71..d3de0455dd0715a0ee8812f43a9eaa1004952a26 100644 (file)
@@ -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.
index 3a3703b267dbf8b1f7c60c72e44fd5883e8713cd..f4872cef10c9af994778dba07c59bdb10bc03d6a 100644 (file)
@@ -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.
index fc714c9339a411992ddf1996804185a81c8cb35f..9e6bfceb49a7919a9cc8093ab27acc4fcba861b4 100644 (file)
@@ -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.