aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMichael Albinus2020-01-14 11:46:42 +0100
committerMichael Albinus2020-01-14 11:46:42 +0100
commit06caa3b7e5e9fe91b6918f8567adbd5501d6dbdd (patch)
tree8dd6754d32ae7a56e87abd1967252a387071c231 /lisp
parent88efc736f562656efab778d35c32d549ef6270d7 (diff)
downloademacs-06caa3b7e5e9fe91b6918f8567adbd5501d6dbdd.tar.gz
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')
-rw-r--r--lisp/net/tramp-adb.el23
-rw-r--r--lisp/net/tramp-sh.el22
2 files changed, 24 insertions, 21 deletions
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 0e4ac536d3a..efe89344216 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -935,6 +935,8 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
935;; We use BUFFER also as connection buffer during setup. Because of 935;; We use BUFFER also as connection buffer during setup. Because of
936;; this, its original contents must be saved, and restored once 936;; this, its original contents must be saved, and restored once
937;; connection has been setup. 937;; connection has been setup.
938;; The complete STDERR buffer is available only when the process has
939;; terminated.
938(defun tramp-adb-handle-make-process (&rest args) 940(defun tramp-adb-handle-make-process (&rest args)
939 "Like `make-process' for Tramp files." 941 "Like `make-process' for Tramp files."
940 (when args 942 (when args
@@ -983,6 +985,8 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
983 (if (and (stringp stderr) (tramp-tramp-file-p stderr)) 985 (if (and (stringp stderr) (tramp-tramp-file-p stderr))
984 (tramp-unquote-file-local-name stderr) 986 (tramp-unquote-file-local-name stderr)
985 (tramp-make-tramp-temp-file v)))) 987 (tramp-make-tramp-temp-file v))))
988 (remote-tmpstderr
989 (and tmpstderr (tramp-make-tramp-file-name v tmpstderr)))
986 (program (car command)) 990 (program (car command))
987 (args (cdr command)) 991 (args (cdr command))
988 (command 992 (command
@@ -1049,9 +1053,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
1049 (add-function 1053 (add-function
1050 :after (process-sentinel p) 1054 :after (process-sentinel p)
1051 (lambda (_proc _msg) 1055 (lambda (_proc _msg)
1052 (rename-file 1056 (rename-file remote-tmpstderr stderr))))
1053 (tramp-make-tramp-file-name v tmpstderr)
1054 stderr))))
1055 ;; Read initial output. Remove the first line, 1057 ;; Read initial output. Remove the first line,
1056 ;; which is the command echo. 1058 ;; which is the command echo.
1057 (while 1059 (while
@@ -1062,20 +1064,19 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
1062 (delete-region (point-min) (point)) 1064 (delete-region (point-min) (point))
1063 ;; Provide error buffer. This shows only 1065 ;; Provide error buffer. This shows only
1064 ;; initial error messages; messages arriving 1066 ;; initial error messages; messages arriving
1065 ;; later on shall be inserted by 1067 ;; later on will be inserted when the process
1066 ;; `auto-revert'. The temporary file will 1068 ;; is deleted. The temporary file will exist
1067 ;; exist until the process is deleted. 1069 ;; until the process is deleted.
1068 (when (bufferp stderr) 1070 (when (bufferp stderr)
1069 (with-current-buffer stderr 1071 (with-current-buffer stderr
1070 (insert-file-contents 1072 (insert-file-contents remote-tmpstderr 'visit))
1071 (tramp-make-tramp-file-name v tmpstderr) 'visit)
1072 (auto-revert-mode))
1073 ;; Delete tmpstderr file. 1073 ;; Delete tmpstderr file.
1074 (add-function 1074 (add-function
1075 :after (process-sentinel p) 1075 :after (process-sentinel p)
1076 (lambda (_proc _msg) 1076 (lambda (_proc _msg)
1077 (delete-file 1077 (with-current-buffer stderr
1078 (tramp-make-tramp-file-name v tmpstderr))))) 1078 (insert-file-contents remote-tmpstderr 'visit))
1079 (delete-file remote-tmpstderr))))
1079 ;; Return process. 1080 ;; Return process.
1080 p)))) 1081 p))))
1081 1082
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."
2806;; We use BUFFER also as connection buffer during setup. Because of 2806;; We use BUFFER also as connection buffer during setup. Because of
2807;; this, its original contents must be saved, and restored once 2807;; this, its original contents must be saved, and restored once
2808;; connection has been setup. 2808;; connection has been setup.
2809;; The complete STDERR buffer is available only when the process has
2810;; terminated.
2809(defun tramp-sh-handle-make-process (&rest args) 2811(defun tramp-sh-handle-make-process (&rest args)
2810 "Like `make-process' for Tramp files. 2812 "Like `make-process' for Tramp files.
2811STDERR can also be a file name." 2813STDERR can also be a file name."
@@ -2855,6 +2857,8 @@ STDERR can also be a file name."
2855 (if (and (stringp stderr) (tramp-tramp-file-p stderr)) 2857 (if (and (stringp stderr) (tramp-tramp-file-p stderr))
2856 (tramp-unquote-file-local-name stderr) 2858 (tramp-unquote-file-local-name stderr)
2857 (tramp-make-tramp-temp-file v)))) 2859 (tramp-make-tramp-temp-file v))))
2860 (remote-tmpstderr
2861 (and tmpstderr (tramp-make-tramp-file-name v tmpstderr)))
2858 (program (car command)) 2862 (program (car command))
2859 (args (cdr command)) 2863 (args (cdr command))
2860 ;; When PROGRAM matches "*sh", and the first arg is 2864 ;; When PROGRAM matches "*sh", and the first arg is
@@ -2994,24 +2998,22 @@ STDERR can also be a file name."
2994 (add-function 2998 (add-function
2995 :after (process-sentinel p) 2999 :after (process-sentinel p)
2996 (lambda (_proc _msg) 3000 (lambda (_proc _msg)
2997 (rename-file 3001 (rename-file remote-tmpstderr stderr))))
2998 (tramp-make-tramp-file-name v tmpstderr) stderr))))
2999 ;; Provide error buffer. This shows only 3002 ;; Provide error buffer. This shows only
3000 ;; initial error messages; messages arriving 3003 ;; initial error messages; messages arriving
3001 ;; later on shall be inserted by `auto-revert'. 3004 ;; later on will be inserted when the process is
3002 ;; The temporary file will exist until the 3005 ;; deleted. The temporary file will exist until
3003 ;; process is deleted. 3006 ;; the process is deleted.
3004 (when (bufferp stderr) 3007 (when (bufferp stderr)
3005 (with-current-buffer stderr 3008 (with-current-buffer stderr
3006 (insert-file-contents 3009 (insert-file-contents remote-tmpstderr 'visit))
3007 (tramp-make-tramp-file-name v tmpstderr) 'visit)
3008 (auto-revert-mode))
3009 ;; Delete tmpstderr file. 3010 ;; Delete tmpstderr file.
3010 (add-function 3011 (add-function
3011 :after (process-sentinel p) 3012 :after (process-sentinel p)
3012 (lambda (_proc _msg) 3013 (lambda (_proc _msg)
3013 (delete-file 3014 (with-current-buffer stderr
3014 (tramp-make-tramp-file-name v tmpstderr))))) 3015 (insert-file-contents remote-tmpstderr 'visit))
3016 (delete-file remote-tmpstderr))))
3015 ;; Return process. 3017 ;; Return process.
3016 p))) 3018 p)))
3017 3019