aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMichael Albinus2020-01-27 10:11:32 +0100
committerMichael Albinus2020-01-27 10:11:32 +0100
commite1c93a02dd13039f7a9f4ccefddaa3e761a27a2e (patch)
treed61cbea1be54bb1491663a1f69f28df1a1fd96f3 /lisp
parent502059433ce0e9699eb73d21656ce6e9e127d63b (diff)
downloademacs-e1c93a02dd13039f7a9f4ccefddaa3e761a27a2e.tar.gz
emacs-e1c93a02dd13039f7a9f4ccefddaa3e761a27a2e.zip
Fix problems in Tramp's async-shell-command
* lisp/net/tramp-adb.el (tramp-adb-handle-make-process): * lisp/net/tramp-cache.el (top): * lisp/net/tramp-sh.el (tramp-sh-handle-make-process): Use `insert-file-contents-literally'. * lisp/net/tramp.el (tramp-parse-file): Use `insert-file-contents-literally'. (tramp-handle-shell-command): Reorganize error-buffer handling. (tramp-handle-start-file-process): Use `consp' instead of `listp'. * test/lisp/net/tramp-tests.el (tramp-test31-interrupt-process): Bind `delete-exited-processes'. (tramp--test-async-shell-command): Bind `delete-exited-processes'. Add additional `accept-process-output'. Move cleanup of output buffer ... (tramp-test32-shell-command): ... here. Test error buffer also for `async-shell-command'.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/net/tramp-adb.el6
-rw-r--r--lisp/net/tramp-cache.el2
-rw-r--r--lisp/net/tramp-sh.el6
-rw-r--r--lisp/net/tramp.el49
4 files changed, 36 insertions, 27 deletions
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 194dd2d308f..aa7fe147c20 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -1065,13 +1065,15 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
1065 ;; until the process is deleted. 1065 ;; until the process is deleted.
1066 (when (bufferp stderr) 1066 (when (bufferp stderr)
1067 (with-current-buffer stderr 1067 (with-current-buffer stderr
1068 (insert-file-contents remote-tmpstderr 'visit)) 1068 (insert-file-contents-literally
1069 remote-tmpstderr 'visit))
1069 ;; Delete tmpstderr file. 1070 ;; Delete tmpstderr file.
1070 (add-function 1071 (add-function
1071 :after (process-sentinel p) 1072 :after (process-sentinel p)
1072 (lambda (_proc _msg) 1073 (lambda (_proc _msg)
1073 (with-current-buffer stderr 1074 (with-current-buffer stderr
1074 (insert-file-contents remote-tmpstderr 'visit)) 1075 (insert-file-contents-literally
1076 remote-tmpstderr 'visit nil nil 'replace))
1075 (delete-file remote-tmpstderr)))) 1077 (delete-file remote-tmpstderr))))
1076 ;; Return process. 1078 ;; Return process.
1077 p)))) 1079 p))))
diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el
index 6ce86b4b65d..92c98486f46 100644
--- a/lisp/net/tramp-cache.el
+++ b/lisp/net/tramp-cache.el
@@ -504,7 +504,7 @@ for all methods. Resulting data are derived from connection history."
504 tramp-cache-read-persistent-data) 504 tramp-cache-read-persistent-data)
505 (condition-case err 505 (condition-case err
506 (with-temp-buffer 506 (with-temp-buffer
507 (insert-file-contents tramp-persistency-file-name) 507 (insert-file-contents-literally tramp-persistency-file-name)
508 (let ((list (read (current-buffer))) 508 (let ((list (read (current-buffer)))
509 (tramp-verbose 0) 509 (tramp-verbose 0)
510 element key item) 510 element key item)
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 23ce048720d..b8f3c0d8c82 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -3004,13 +3004,15 @@ STDERR can also be a file name."
3004 ;; the process is deleted. 3004 ;; the process is deleted.
3005 (when (bufferp stderr) 3005 (when (bufferp stderr)
3006 (with-current-buffer stderr 3006 (with-current-buffer stderr
3007 (insert-file-contents remote-tmpstderr 'visit)) 3007 (insert-file-contents-literally
3008 remote-tmpstderr 'visit))
3008 ;; Delete tmpstderr file. 3009 ;; Delete tmpstderr file.
3009 (add-function 3010 (add-function
3010 :after (process-sentinel p) 3011 :after (process-sentinel p)
3011 (lambda (_proc _msg) 3012 (lambda (_proc _msg)
3012 (with-current-buffer stderr 3013 (with-current-buffer stderr
3013 (insert-file-contents remote-tmpstderr 'visit)) 3014 (insert-file-contents-literally
3015 remote-tmpstderr 'visit nil nil 'replace))
3014 (delete-file remote-tmpstderr)))) 3016 (delete-file remote-tmpstderr))))
3015 ;; Return process. 3017 ;; Return process.
3016 p))) 3018 p)))
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 61f6f2ed3a7..e5bb094bbd5 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -2844,7 +2844,7 @@ User is always nil."
2844 (let ((default-directory (tramp-compat-temporary-file-directory))) 2844 (let ((default-directory (tramp-compat-temporary-file-directory)))
2845 (when (file-readable-p filename) 2845 (when (file-readable-p filename)
2846 (with-temp-buffer 2846 (with-temp-buffer
2847 (insert-file-contents filename) 2847 (insert-file-contents-literally filename)
2848 (goto-char (point-min)) 2848 (goto-char (point-min))
2849 (cl-loop while (not (eobp)) collect (funcall function)))))) 2849 (cl-loop while (not (eobp)) collect (funcall function))))))
2850 2850
@@ -3699,32 +3699,37 @@ support symbolic links."
3699 ;; Run the process. 3699 ;; Run the process.
3700 (setq p (start-file-process-shell-command 3700 (setq p (start-file-process-shell-command
3701 (buffer-name output-buffer) buffer command)) 3701 (buffer-name output-buffer) buffer command))
3702 (if (process-live-p p) 3702 ;; Insert error messages if they were separated.
3703 ;; Display output. 3703 (when (consp buffer)
3704 (with-current-buffer output-buffer
3705 (display-buffer output-buffer '(nil (allow-no-window . t)))
3706 (setq mode-line-process '(":%s"))
3707 (shell-mode)
3708 (set-process-filter p #'comint-output-filter)
3709 (set-process-sentinel
3710 p (if (listp buffer)
3711 (lambda (_proc _string)
3712 (with-current-buffer error-buffer
3713 (insert-file-contents (cadr buffer)))
3714 (delete-file (cadr buffer)))
3715 #'shell-command-sentinel)))
3716 ;; Show stderr.
3717 (with-current-buffer error-buffer 3704 (with-current-buffer error-buffer
3718 (insert-file-contents (cadr buffer))) 3705 (insert-file-contents-literally (cadr buffer))))
3719 (delete-file (cadr buffer))))) 3706 (if (process-live-p p)
3707 ;; Display output.
3708 (with-current-buffer output-buffer
3709 (display-buffer output-buffer '(nil (allow-no-window . t)))
3710 (setq mode-line-process '(":%s"))
3711 (shell-mode)
3712 (set-process-filter p #'comint-output-filter)
3713 (set-process-sentinel p #'shell-command-sentinel)
3714 (when (consp buffer)
3715 (add-function
3716 :after (process-sentinel p)
3717 (lambda (_proc _string)
3718 (with-current-buffer error-buffer
3719 (insert-file-contents-literally
3720 (cadr buffer) nil nil nil 'replace))
3721 (delete-file (cadr buffer))))))
3722
3723 (when (consp buffer)
3724 (delete-file (cadr buffer))))))
3720 3725
3721 (prog1 3726 (prog1
3722 ;; Run the process. 3727 ;; Run the process.
3723 (process-file-shell-command command nil buffer nil) 3728 (process-file-shell-command command nil buffer nil)
3724 ;; Insert error messages if they were separated. 3729 ;; Insert error messages if they were separated.
3725 (when (listp buffer) 3730 (when (consp buffer)
3726 (with-current-buffer error-buffer 3731 (with-current-buffer error-buffer
3727 (insert-file-contents (cadr buffer))) 3732 (insert-file-contents-literally (cadr buffer)))
3728 (delete-file (cadr buffer))) 3733 (delete-file (cadr buffer)))
3729 (if current-buffer-p 3734 (if current-buffer-p
3730 ;; This is like exchange-point-and-mark, but doesn't 3735 ;; This is like exchange-point-and-mark, but doesn't
@@ -3745,10 +3750,10 @@ BUFFER might be a list, in this case STDERR is separated."
3745 (tramp-file-name-handler 3750 (tramp-file-name-handler
3746 'make-process 3751 'make-process
3747 :name name 3752 :name name
3748 :buffer (if (listp buffer) (car buffer) buffer) 3753 :buffer (if (consp buffer) (car buffer) buffer)
3749 :command (and program (cons program args)) 3754 :command (and program (cons program args))
3750 ;; `shell-command' adds an errfile to `buffer'. 3755 ;; `shell-command' adds an errfile to `buffer'.
3751 :stderr (when (listp buffer) (cadr buffer)) 3756 :stderr (when (consp buffer) (cadr buffer))
3752 :noquery nil 3757 :noquery nil
3753 :file-handler t)) 3758 :file-handler t))
3754 3759