]> git.eshelyaron.com Git - emacs.git/commitdiff
Tramp code cleanup
authorMichael Albinus <michael.albinus@gmx.de>
Tue, 21 Jun 2022 12:59:46 +0000 (14:59 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Tue, 21 Jun 2022 12:59:46 +0000 (14:59 +0200)
* lisp/net/tramp-adb.el (tramp-adb-handle-make-process):
* lisp/net/tramp-sh.el (tramp-sh-handle-make-process):
Improve handling of "process-name" and "process-buffer" connection
properties.

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

index ebcdf00c488ba14fcf5544ec7e71eaa144101d97..9981cc3c13848c78d23925f73bc7be83b84f9c7e 100644 (file)
@@ -1048,8 +1048,7 @@ implementation will be used."
                    ;; Save exit.
                    (if (string-prefix-p tramp-temp-buffer-name (buffer-name))
                        (ignore-errors
-                         (set-process-buffer
-                          (tramp-get-connection-process v) nil)
+                         (set-process-buffer p nil)
                          (kill-buffer (current-buffer)))
                      (set-buffer-modified-p bmp))))))))))))
 
index eccc15efe76a50f40ac0c20b52cdd095fa466720..f2e91a1977ec5abc529774267a284f78cdb04524 100644 (file)
@@ -2977,13 +2977,13 @@ implementation will be used."
                    name1 (format "%s<%d>" name i)))
            (setq name name1)
 
-           (with-current-buffer (tramp-get-connection-buffer v)
-             (unwind-protect
-                 (with-tramp-saved-connection-property v "process-name"
-                   (with-tramp-saved-connection-property v "process-buffer"
-                     ;; Set the new process properties.
-                     (tramp-set-connection-property v "process-name" name)
-                     (tramp-set-connection-property v "process-buffer" buffer)
+           (with-tramp-saved-connection-property v "process-name"
+             (with-tramp-saved-connection-property v "process-buffer"
+               ;; Set the new process properties.
+               (tramp-set-connection-property v "process-name" name)
+               (tramp-set-connection-property v "process-buffer" buffer)
+               (with-current-buffer (tramp-get-connection-buffer v)
+                 (unwind-protect
                      ;; We catch this event.  Otherwise,
                      ;; `make-process' could be called on the local
                      ;; host.
@@ -3049,6 +3049,10 @@ implementation will be used."
                            (ignore-errors
                              (set-process-query-on-exit-flag p (null noquery))
                              (set-marker (process-mark p) (point)))
+                           ;; We must flush them here already;
+                           ;; otherwise `delete-file' will fail.
+                           (tramp-flush-connection-property v "process-name")
+                           (tramp-flush-connection-property v "process-buffer")
                            ;; Kill stderr process and delete named pipe.
                            (when (bufferp stderr)
                              (add-function
@@ -3061,14 +3065,14 @@ implementation will be used."
                                 (ignore-errors
                                   (delete-file remote-tmpstderr)))))
                            ;; Return process.
-                           p)))))
-
-               ;; Save exit.
-               (if (string-prefix-p tramp-temp-buffer-name (buffer-name))
-                   (ignore-errors
-                     (set-process-buffer p nil)
-                     (kill-buffer (current-buffer)))
-                 (set-buffer-modified-p bmp))))))))))
+                           p)))
+
+                   ;; Save exit.
+                   (if (string-prefix-p tramp-temp-buffer-name (buffer-name))
+                       (ignore-errors
+                         (set-process-buffer p nil)
+                         (kill-buffer (current-buffer)))
+                     (set-buffer-modified-p bmp))))))))))))
 
 (defun tramp-sh-get-signal-strings (vec)
   "Strings to return by `process-file' in case of signals."