diff options
| author | Michael Albinus | 2022-06-19 21:07:29 +0200 |
|---|---|---|
| committer | Michael Albinus | 2022-06-19 21:07:29 +0200 |
| commit | 694d7984a347652bd0ff337056b9e616dc5aaee8 (patch) | |
| tree | 3353e148adcacd9648c906c55afa376d75325ad2 | |
| parent | 1de63a3969d98b47776f12b985d055caacb5a702 (diff) | |
| download | emacs-694d7984a347652bd0ff337056b9e616dc5aaee8.tar.gz emacs-694d7984a347652bd0ff337056b9e616dc5aaee8.zip | |
Fix last change in tramp-adb-handle-make-process
* lisp/net/tramp-adb.el (tramp-adb-handle-make-process):
Fix process buffer management.
| -rw-r--r-- | lisp/net/tramp-adb.el | 128 |
1 files changed, 65 insertions, 63 deletions
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 0c3d87cc919..ebcdf00c488 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el | |||
| @@ -955,18 +955,18 @@ implementation will be used." | |||
| 955 | name1 (format "%s<%d>" name i))) | 955 | name1 (format "%s<%d>" name i))) |
| 956 | (setq name name1) | 956 | (setq name name1) |
| 957 | 957 | ||
| 958 | (with-current-buffer (tramp-get-connection-buffer v) | 958 | (with-tramp-saved-connection-property v "process-name" |
| 959 | (unwind-protect | 959 | (with-tramp-saved-connection-property v "process-buffer" |
| 960 | ;; We catch this event. Otherwise, `make-process' | 960 | ;; Set the new process properties. |
| 961 | ;; could be called on the local host. | 961 | (tramp-set-connection-property v "process-name" name) |
| 962 | (save-excursion | 962 | (tramp-set-connection-property v "process-buffer" buffer) |
| 963 | (save-restriction | 963 | (with-current-buffer (tramp-get-connection-buffer v) |
| 964 | (with-tramp-saved-connection-property v "process-name" | 964 | (unwind-protect |
| 965 | (with-tramp-saved-connection-property v "process-buffer" | 965 | ;; We catch this event. Otherwise, |
| 966 | ;; Set the new process properties. | 966 | ;; `make-process' could be called on the local |
| 967 | (tramp-set-connection-property v "process-name" name) | 967 | ;; host. |
| 968 | (tramp-set-connection-property | 968 | (save-excursion |
| 969 | v "process-buffer" buffer) | 969 | (save-restriction |
| 970 | ;; Activate narrowing in order to save | 970 | ;; Activate narrowing in order to save |
| 971 | ;; BUFFER contents. Clear also the | 971 | ;; BUFFER contents. Clear also the |
| 972 | ;; modification time; otherwise we might be | 972 | ;; modification time; otherwise we might be |
| @@ -980,8 +980,7 @@ implementation will be used." | |||
| 980 | (clear-visited-file-modtime) | 980 | (clear-visited-file-modtime) |
| 981 | (narrow-to-region (point-max) (point-max)) | 981 | (narrow-to-region (point-max) (point-max)) |
| 982 | ;; We call `tramp-adb-maybe-open-connection', | 982 | ;; We call `tramp-adb-maybe-open-connection', |
| 983 | ;; in order to cleanup the prompt | 983 | ;; in order to cleanup the prompt afterwards. |
| 984 | ;; afterwards. | ||
| 985 | (tramp-adb-maybe-open-connection v) | 984 | (tramp-adb-maybe-open-connection v) |
| 986 | (delete-region (point-min) (point-max)) | 985 | (delete-region (point-min) (point-max)) |
| 987 | ;; Send the command. | 986 | ;; Send the command. |
| @@ -1001,55 +1000,58 @@ implementation will be used." | |||
| 1001 | ;; already. | 1000 | ;; already. |
| 1002 | (ignore-errors | 1001 | (ignore-errors |
| 1003 | (set-process-query-on-exit-flag p (null noquery)) | 1002 | (set-process-query-on-exit-flag p (null noquery)) |
| 1004 | (set-marker (process-mark p) (point)))) | 1003 | (set-marker (process-mark p) (point)) |
| 1005 | 1004 | ;; We must flush them here already; | |
| 1006 | ;; Copy tmpstderr file. "process-buffer" | 1005 | ;; otherwise `rename-file', `delete-file' or |
| 1007 | ;; and "process-name" must be reset already; | 1006 | ;; `insert-file-contents' will fail. |
| 1008 | ;; otherwise `rename-file', `delete-file' or | 1007 | (tramp-flush-connection-property v "process-name") |
| 1009 | ;; `insert-file-contents' will fail. | 1008 | (tramp-flush-connection-property |
| 1010 | (when (and (stringp stderr) | 1009 | v "process-buffer") |
| 1011 | (not (tramp-tramp-file-p stderr))) | 1010 | ;; Copy tmpstderr file. |
| 1012 | (add-function | 1011 | (when (and (stringp stderr) |
| 1013 | :after (process-sentinel p) | 1012 | (not (tramp-tramp-file-p stderr))) |
| 1014 | (lambda (_proc _msg) | 1013 | (add-function |
| 1015 | (rename-file remote-tmpstderr stderr)))) | 1014 | :after (process-sentinel p) |
| 1016 | ;; Read initial output. Remove the first | 1015 | (lambda (_proc _msg) |
| 1017 | ;; line, which is the command echo. | 1016 | (rename-file remote-tmpstderr stderr)))) |
| 1018 | (unless (eq filter t) | 1017 | ;; Read initial output. Remove the |
| 1019 | (while | 1018 | ;; first line, which is the command |
| 1020 | (progn | 1019 | ;; echo. |
| 1021 | (goto-char (point-min)) | 1020 | (unless (eq filter t) |
| 1022 | (not (re-search-forward "[\n]" nil t))) | 1021 | (while |
| 1023 | (tramp-accept-process-output p 0)) | 1022 | (progn |
| 1024 | (delete-region (point-min) (point))) | 1023 | (goto-char (point-min)) |
| 1025 | ;; Provide error buffer. This shows only | 1024 | (not (re-search-forward "[\n]" nil t))) |
| 1026 | ;; initial error messages; messages arriving | 1025 | (tramp-accept-process-output p 0)) |
| 1027 | ;; later on will be inserted when the | 1026 | (delete-region (point-min) (point))) |
| 1028 | ;; process is deleted. The temporary file | 1027 | ;; Provide error buffer. This shows |
| 1029 | ;; will exist until the process is deleted. | 1028 | ;; only initial error messages; messages |
| 1030 | (when (bufferp stderr) | 1029 | ;; arriving later on will be inserted |
| 1031 | (with-current-buffer stderr | 1030 | ;; when the process is deleted. The |
| 1032 | (insert-file-contents-literally | 1031 | ;; temporary file will exist until the |
| 1033 | remote-tmpstderr 'visit)) | 1032 | ;; process is deleted. |
| 1034 | ;; Delete tmpstderr file. | 1033 | (when (bufferp stderr) |
| 1035 | (add-function | 1034 | (with-current-buffer stderr |
| 1036 | :after (process-sentinel p) | 1035 | (insert-file-contents-literally |
| 1037 | (lambda (_proc _msg) | 1036 | remote-tmpstderr 'visit)) |
| 1038 | (with-current-buffer stderr | 1037 | ;; Delete tmpstderr file. |
| 1039 | (insert-file-contents-literally | 1038 | (add-function |
| 1040 | remote-tmpstderr 'visit nil nil 'replace)) | 1039 | :after (process-sentinel p) |
| 1041 | (delete-file remote-tmpstderr)))) | 1040 | (lambda (_proc _msg) |
| 1042 | ;; Return process. | 1041 | (with-current-buffer stderr |
| 1043 | p)))) | 1042 | (insert-file-contents-literally |
| 1044 | 1043 | remote-tmpstderr 'visit nil nil 'replace)) | |
| 1045 | ;; Save exit. | 1044 | (delete-file remote-tmpstderr)))) |
| 1046 | ;; FIXME: Does `tramp-get-connection-process' return | 1045 | ;; Return process. |
| 1047 | ;; the proper value? | 1046 | p)))) |
| 1048 | (if (string-prefix-p tramp-temp-buffer-name (buffer-name)) | 1047 | |
| 1049 | (ignore-errors | 1048 | ;; Save exit. |
| 1050 | (set-process-buffer (tramp-get-connection-process v) nil) | 1049 | (if (string-prefix-p tramp-temp-buffer-name (buffer-name)) |
| 1051 | (kill-buffer (current-buffer))) | 1050 | (ignore-errors |
| 1052 | (set-buffer-modified-p bmp)))))))))) | 1051 | (set-process-buffer |
| 1052 | (tramp-get-connection-process v) nil) | ||
| 1053 | (kill-buffer (current-buffer))) | ||
| 1054 | (set-buffer-modified-p bmp)))))))))))) | ||
| 1053 | 1055 | ||
| 1054 | (defun tramp-adb-handle-exec-path () | 1056 | (defun tramp-adb-handle-exec-path () |
| 1055 | "Like `exec-path' for Tramp files." | 1057 | "Like `exec-path' for Tramp files." |