From 0939465300f7c80f110c8596c0388f555619ea62 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Tue, 21 Jun 2022 14:59:46 +0200 Subject: [PATCH] Tramp code cleanup * 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 | 3 +-- lisp/net/tramp-sh.el | 34 +++++++++++++++++++--------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index ebcdf00c488..9981cc3c138 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -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)))))))))))) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index eccc15efe76..f2e91a1977e 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -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." -- 2.39.2