emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 694d7984a3: Fix last change in tramp-adb-handle-make-process


From: Michael Albinus
Subject: master 694d7984a3: Fix last change in tramp-adb-handle-make-process
Date: Sun, 19 Jun 2022 15:07:39 -0400 (EDT)

branch: master
commit 694d7984a347652bd0ff337056b9e616dc5aaee8
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    Fix last change in tramp-adb-handle-make-process
    
    * lisp/net/tramp-adb.el (tramp-adb-handle-make-process):
    Fix process buffer management.
---
 lisp/net/tramp-adb.el | 128 +++++++++++++++++++++++++-------------------------
 1 file changed, 65 insertions(+), 63 deletions(-)

diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 0c3d87cc91..ebcdf00c48 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -955,18 +955,18 @@ implementation will be used."
                    name1 (format "%s<%d>" name i)))
            (setq name name1)
 
-           (with-current-buffer (tramp-get-connection-buffer v)
-             (unwind-protect
-                 ;; We catch this event.  Otherwise, `make-process'
-                 ;; could be called on the local host.
-                 (save-excursion
-                   (save-restriction
-                     (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.
+                     (save-excursion
+                       (save-restriction
                          ;; Activate narrowing in order to save
                          ;; BUFFER contents.  Clear also the
                          ;; modification time; otherwise we might be
@@ -980,8 +980,7 @@ implementation will be used."
                            (clear-visited-file-modtime)
                            (narrow-to-region (point-max) (point-max))
                            ;; We call `tramp-adb-maybe-open-connection',
-                           ;; in order to cleanup the prompt
-                           ;; afterwards.
+                           ;; in order to cleanup the prompt afterwards.
                            (tramp-adb-maybe-open-connection v)
                            (delete-region (point-min) (point-max))
                            ;; Send the command.
@@ -1001,55 +1000,58 @@ implementation will be used."
                            ;; already.
                            (ignore-errors
                              (set-process-query-on-exit-flag p (null noquery))
-                             (set-marker (process-mark p) (point))))
-
-                         ;; Copy tmpstderr file.  "process-buffer"
-                         ;; and "process-name" must be reset already;
-                         ;; otherwise `rename-file', `delete-file' or
-                         ;; `insert-file-contents' will fail.
-                         (when (and (stringp stderr)
-                                    (not (tramp-tramp-file-p stderr)))
-                           (add-function
-                            :after (process-sentinel p)
-                            (lambda (_proc _msg)
-                              (rename-file remote-tmpstderr stderr))))
-                         ;; Read initial output.  Remove the first
-                         ;; line, which is the command echo.
-                         (unless (eq filter t)
-                           (while
-                               (progn
-                                 (goto-char (point-min))
-                                 (not (re-search-forward "[\n]" nil t)))
-                             (tramp-accept-process-output p 0))
-                           (delete-region (point-min) (point)))
-                         ;; Provide error buffer.  This shows only
-                         ;; initial error messages; messages arriving
-                         ;; later on will be inserted when the
-                         ;; process is deleted.  The temporary file
-                         ;; will exist until the process is deleted.
-                         (when (bufferp stderr)
-                           (with-current-buffer stderr
-                             (insert-file-contents-literally
-                              remote-tmpstderr 'visit))
-                           ;; Delete tmpstderr file.
-                           (add-function
-                            :after (process-sentinel p)
-                            (lambda (_proc _msg)
-                              (with-current-buffer stderr
-                                (insert-file-contents-literally
-                                 remote-tmpstderr 'visit nil nil 'replace))
-                              (delete-file remote-tmpstderr))))
-                         ;; Return process.
-                         p))))
-
-               ;; Save exit.
-               ;; FIXME: Does `tramp-get-connection-process' return
-               ;; the proper value?
-               (if (string-prefix-p tramp-temp-buffer-name (buffer-name))
-                   (ignore-errors
-                     (set-process-buffer (tramp-get-connection-process v) nil)
-                     (kill-buffer (current-buffer)))
-                 (set-buffer-modified-p bmp))))))))))
+                             (set-marker (process-mark p) (point))
+                             ;; We must flush them here already;
+                             ;; otherwise `rename-file', `delete-file' or
+                             ;; `insert-file-contents' will fail.
+                             (tramp-flush-connection-property v "process-name")
+                             (tramp-flush-connection-property
+                              v "process-buffer")
+                             ;; Copy tmpstderr file.
+                             (when (and (stringp stderr)
+                                        (not (tramp-tramp-file-p stderr)))
+                               (add-function
+                                :after (process-sentinel p)
+                                (lambda (_proc _msg)
+                                  (rename-file remote-tmpstderr stderr))))
+                             ;; Read initial output.  Remove the
+                             ;; first line, which is the command
+                             ;; echo.
+                             (unless (eq filter t)
+                               (while
+                                   (progn
+                                     (goto-char (point-min))
+                                     (not (re-search-forward "[\n]" nil t)))
+                                 (tramp-accept-process-output p 0))
+                               (delete-region (point-min) (point)))
+                             ;; Provide error buffer.  This shows
+                             ;; only initial error messages; messages
+                             ;; arriving later on will be inserted
+                             ;; when the process is deleted.  The
+                             ;; temporary file will exist until the
+                             ;; process is deleted.
+                             (when (bufferp stderr)
+                               (with-current-buffer stderr
+                                 (insert-file-contents-literally
+                                  remote-tmpstderr 'visit))
+                               ;; Delete tmpstderr file.
+                               (add-function
+                                :after (process-sentinel p)
+                                (lambda (_proc _msg)
+                                  (with-current-buffer stderr
+                                    (insert-file-contents-literally
+                                     remote-tmpstderr 'visit nil nil 'replace))
+                                  (delete-file remote-tmpstderr))))
+                             ;; Return process.
+                             p))))
+
+                   ;; Save exit.
+                   (if (string-prefix-p tramp-temp-buffer-name (buffer-name))
+                       (ignore-errors
+                         (set-process-buffer
+                          (tramp-get-connection-process v) nil)
+                         (kill-buffer (current-buffer)))
+                     (set-buffer-modified-p bmp))))))))))))
 
 (defun tramp-adb-handle-exec-path ()
   "Like `exec-path' for Tramp files."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]