diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2020-01-14 11:46:42 +0100 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2020-01-14 11:46:42 +0100 |
commit | 06caa3b7e5e9fe91b6918f8567adbd5501d6dbdd (patch) | |
tree | 8dd6754d32ae7a56e87abd1967252a387071c231 /lisp/net/tramp-sh.el | |
parent | 88efc736f562656efab778d35c32d549ef6270d7 (diff) | |
download | emacs-06caa3b7e5e9fe91b6918f8567adbd5501d6dbdd.tar.gz emacs-06caa3b7e5e9fe91b6918f8567adbd5501d6dbdd.tar.bz2 emacs-06caa3b7e5e9fe91b6918f8567adbd5501d6dbdd.zip |
Refactor Tramp async process code
* lisp/net/tramp-adb.el (tramp-adb-handle-make-process):
* lisp/net/tramp-sh.el (tramp-sh-handle-make-process):
Update stderr buffer when process has finished. Do not call
`auto-revert'.
* test/lisp/net/tramp-tests.el (tramp-test31-interrupt-process):
Tag it :unstable. Change `accept-process-output' arguments.
(tramp--test-async-shell-command): New defun.
(tramp--test-shell-command-to-string-asynchronously): Use it.
(tramp-test32-shell-command): Refactor code.
Diffstat (limited to 'lisp/net/tramp-sh.el')
-rw-r--r-- | lisp/net/tramp-sh.el | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 6e5b9d243fb..4ca1f651734 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -2806,6 +2806,8 @@ the result will be a local, non-Tramp, file name." ;; We use BUFFER also as connection buffer during setup. Because of ;; this, its original contents must be saved, and restored once ;; connection has been setup. +;; The complete STDERR buffer is available only when the process has +;; terminated. (defun tramp-sh-handle-make-process (&rest args) "Like `make-process' for Tramp files. STDERR can also be a file name." @@ -2855,6 +2857,8 @@ STDERR can also be a file name." (if (and (stringp stderr) (tramp-tramp-file-p stderr)) (tramp-unquote-file-local-name stderr) (tramp-make-tramp-temp-file v)))) + (remote-tmpstderr + (and tmpstderr (tramp-make-tramp-file-name v tmpstderr))) (program (car command)) (args (cdr command)) ;; When PROGRAM matches "*sh", and the first arg is @@ -2994,24 +2998,22 @@ STDERR can also be a file name." (add-function :after (process-sentinel p) (lambda (_proc _msg) - (rename-file - (tramp-make-tramp-file-name v tmpstderr) stderr)))) + (rename-file remote-tmpstderr stderr)))) ;; Provide error buffer. This shows only ;; initial error messages; messages arriving - ;; later on shall be inserted by `auto-revert'. - ;; The temporary file will exist until the - ;; process is deleted. + ;; 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 - (tramp-make-tramp-file-name v tmpstderr) 'visit) - (auto-revert-mode)) + (insert-file-contents remote-tmpstderr 'visit)) ;; Delete tmpstderr file. (add-function :after (process-sentinel p) (lambda (_proc _msg) - (delete-file - (tramp-make-tramp-file-name v tmpstderr))))) + (with-current-buffer stderr + (insert-file-contents remote-tmpstderr 'visit)) + (delete-file remote-tmpstderr)))) ;; Return process. p))) |