diff options
| author | Michael Albinus | 2018-12-25 11:08:30 +0100 |
|---|---|---|
| committer | Michael Albinus | 2018-12-25 11:08:30 +0100 |
| commit | 9fe788a1fa02c6b717c709773f3cca7bc8b2ebe6 (patch) | |
| tree | f6f4a0d8654c3423bbef29dfa1b5697f1858389c | |
| parent | a94ac604d8c9848b0414ade80a1920b345161656 (diff) | |
| download | emacs-9fe788a1fa02c6b717c709773f3cca7bc8b2ebe6.tar.gz emacs-9fe788a1fa02c6b717c709773f3cca7bc8b2ebe6.zip | |
Provide tramp-adb-handle-make-process
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
Add `tramp-adb-handle-make-process' and
`tramp-handle-start-file-process'.
(tramp-adb-handle-make-process): New defun, derived from
`tramp-adb-handle-start-file-process'. (Bug#28691)
| -rw-r--r-- | lisp/net/tramp-adb.el | 195 |
1 files changed, 116 insertions, 79 deletions
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 5f0b9dad31d..e0bfee68392 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el | |||
| @@ -144,7 +144,7 @@ It is used for TCP/IP devices." | |||
| 144 | (make-directory . tramp-adb-handle-make-directory) | 144 | (make-directory . tramp-adb-handle-make-directory) |
| 145 | (make-directory-internal . ignore) | 145 | (make-directory-internal . ignore) |
| 146 | (make-nearby-temp-file . tramp-handle-make-nearby-temp-file) | 146 | (make-nearby-temp-file . tramp-handle-make-nearby-temp-file) |
| 147 | (make-process . ignore) | 147 | (make-process . tramp-adb-handle-make-process) |
| 148 | (make-symbolic-link . tramp-handle-make-symbolic-link) | 148 | (make-symbolic-link . tramp-handle-make-symbolic-link) |
| 149 | (process-file . tramp-adb-handle-process-file) | 149 | (process-file . tramp-adb-handle-process-file) |
| 150 | (rename-file . tramp-adb-handle-rename-file) | 150 | (rename-file . tramp-adb-handle-rename-file) |
| @@ -154,7 +154,7 @@ It is used for TCP/IP devices." | |||
| 154 | (set-file-times . tramp-adb-handle-set-file-times) | 154 | (set-file-times . tramp-adb-handle-set-file-times) |
| 155 | (set-visited-file-modtime . tramp-handle-set-visited-file-modtime) | 155 | (set-visited-file-modtime . tramp-handle-set-visited-file-modtime) |
| 156 | (shell-command . tramp-adb-handle-shell-command) | 156 | (shell-command . tramp-adb-handle-shell-command) |
| 157 | (start-file-process . tramp-adb-handle-start-file-process) | 157 | (start-file-process . tramp-handle-start-file-process) |
| 158 | (substitute-in-file-name . tramp-handle-substitute-in-file-name) | 158 | (substitute-in-file-name . tramp-handle-substitute-in-file-name) |
| 159 | (temporary-file-directory . tramp-handle-temporary-file-directory) | 159 | (temporary-file-directory . tramp-handle-temporary-file-directory) |
| 160 | (tramp-set-file-uid-gid . ignore) | 160 | (tramp-set-file-uid-gid . ignore) |
| @@ -1017,83 +1017,120 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." | |||
| 1017 | ;; We use BUFFER also as connection buffer during setup. Because of | 1017 | ;; We use BUFFER also as connection buffer during setup. Because of |
| 1018 | ;; this, its original contents must be saved, and restored once | 1018 | ;; this, its original contents must be saved, and restored once |
| 1019 | ;; connection has been setup. | 1019 | ;; connection has been setup. |
| 1020 | (defun tramp-adb-handle-start-file-process (name buffer program &rest args) | 1020 | (defun tramp-adb-handle-make-process (&rest args) |
| 1021 | "Like `start-file-process' for Tramp files." | 1021 | "Like `make-process' for Tramp files." |
| 1022 | (with-parsed-tramp-file-name default-directory nil | 1022 | (when args |
| 1023 | ;; When PROGRAM is nil, we should provide a tty. This is not | 1023 | (with-parsed-tramp-file-name (expand-file-name default-directory) nil |
| 1024 | ;; possible here. | 1024 | (let ((name (plist-get args :name)) |
| 1025 | (unless (stringp program) | 1025 | (buffer (plist-get args :buffer)) |
| 1026 | (tramp-error v 'file-error "PROGRAM must be a string")) | 1026 | (command (plist-get args :command)) |
| 1027 | 1027 | (coding (plist-get args :coding)) | |
| 1028 | (let* ((buffer | 1028 | (noquery (plist-get args :noquery)) |
| 1029 | (if buffer | 1029 | (stop (plist-get args :stop)) |
| 1030 | (get-buffer-create buffer) | 1030 | (connection-type (plist-get args :connection-type)) |
| 1031 | ;; BUFFER can be nil. We use a temporary buffer. | 1031 | (filter (plist-get args :filter)) |
| 1032 | (generate-new-buffer tramp-temp-buffer-name))) | 1032 | (sentinel (plist-get args :sentinel)) |
| 1033 | (command | 1033 | (stderr (plist-get args :stderr))) |
| 1034 | (format "cd %s; %s" | 1034 | (unless (stringp name) |
| 1035 | (tramp-shell-quote-argument localname) | 1035 | (signal 'wrong-type-argument (list 'stringp name))) |
| 1036 | (mapconcat 'tramp-shell-quote-argument | 1036 | (unless (or (null buffer) (bufferp buffer) (stringp buffer)) |
| 1037 | (cons program args) " "))) | 1037 | (signal 'wrong-type-argument (list 'stringp buffer))) |
| 1038 | (tramp-process-connection-type | 1038 | (unless (consp command) |
| 1039 | (or (null program) tramp-process-connection-type)) | 1039 | (signal 'wrong-type-argument (list 'consp command))) |
| 1040 | (bmp (and (buffer-live-p buffer) (buffer-modified-p buffer))) | 1040 | (unless (or (null coding) |
| 1041 | (name1 name) | 1041 | (and (symbolp coding) (memq coding coding-system-list)) |
| 1042 | (i 0) | 1042 | (and (consp coding) |
| 1043 | ;; We do not want to run timers. | 1043 | (memq (car coding) coding-system-list) |
| 1044 | timer-list timer-idle-list) | 1044 | (memq (cdr coding) coding-system-list))) |
| 1045 | 1045 | (signal 'wrong-type-argument (list 'symbolp coding))) | |
| 1046 | (while (get-process name1) | 1046 | (unless (or (null connection-type) (memq connection-type '(pipe pty))) |
| 1047 | ;; NAME must be unique as process name. | 1047 | (signal 'wrong-type-argument (list 'symbolp connection-type))) |
| 1048 | (setq i (1+ i) | 1048 | (unless (or (null filter) (functionp filter)) |
| 1049 | name1 (format "%s<%d>" name i))) | 1049 | (signal 'wrong-type-argument (list 'functionp filter))) |
| 1050 | (setq name name1) | 1050 | (unless (or (null sentinel) (functionp sentinel)) |
| 1051 | ;; Set the new process properties. | 1051 | (signal 'wrong-type-argument (list 'functionp sentinel))) |
| 1052 | (tramp-set-connection-property v "process-name" name) | 1052 | (unless (or (null stderr) (bufferp stderr) (stringp stderr)) |
| 1053 | (tramp-set-connection-property v "process-buffer" buffer) | 1053 | (signal 'wrong-type-argument (list 'stringp stderr))) |
| 1054 | 1054 | ||
| 1055 | (with-current-buffer (tramp-get-connection-buffer v) | 1055 | (let* ((buffer |
| 1056 | (unwind-protect | 1056 | (if buffer |
| 1057 | ;; We catch this event. Otherwise, `start-process' could | 1057 | (get-buffer-create buffer) |
| 1058 | ;; be called on the local host. | 1058 | ;; BUFFER can be nil. We use a temporary buffer. |
| 1059 | (save-excursion | 1059 | (generate-new-buffer tramp-temp-buffer-name))) |
| 1060 | (save-restriction | 1060 | (program (car command)) |
| 1061 | ;; Activate narrowing in order to save BUFFER | 1061 | (args (cdr command)) |
| 1062 | ;; contents. Clear also the modification time; | 1062 | (command |
| 1063 | ;; otherwise we might be interrupted by | 1063 | (format "cd %s; %s" |
| 1064 | ;; `verify-visited-file-modtime'. | 1064 | (tramp-shell-quote-argument localname) |
| 1065 | (let ((buffer-undo-list t) | 1065 | (mapconcat 'tramp-shell-quote-argument |
| 1066 | (buffer-read-only nil) | 1066 | (cons program args) " "))) |
| 1067 | (mark (point))) | 1067 | (tramp-process-connection-type |
| 1068 | (clear-visited-file-modtime) | 1068 | (or (null program) tramp-process-connection-type)) |
| 1069 | (narrow-to-region (point-max) (point-max)) | 1069 | (bmp (and (buffer-live-p buffer) (buffer-modified-p buffer))) |
| 1070 | ;; We call `tramp-adb-maybe-open-connection', in | 1070 | (name1 name) |
| 1071 | ;; order to cleanup the prompt afterwards. | 1071 | (i 0) |
| 1072 | (tramp-adb-maybe-open-connection v) | 1072 | ;; We do not want to run timers. |
| 1073 | (widen) | 1073 | timer-list timer-idle-list) |
| 1074 | (delete-region mark (point)) | 1074 | |
| 1075 | (narrow-to-region (point-max) (point-max)) | 1075 | (while (get-process name1) |
| 1076 | ;; Send the command. | 1076 | ;; NAME must be unique as process name. |
| 1077 | (let ((tramp-adb-prompt (regexp-quote command))) | 1077 | (setq i (1+ i) |
| 1078 | (tramp-adb-send-command v command)) | 1078 | name1 (format "%s<%d>" name i))) |
| 1079 | (let ((p (tramp-get-connection-process v))) | 1079 | (setq name name1) |
| 1080 | ;; Set query flag and process marker for this | 1080 | ;; Set the new process properties. |
| 1081 | ;; process. We ignore errors, because the process | 1081 | (tramp-set-connection-property v "process-name" name) |
| 1082 | ;; could have finished already. | 1082 | (tramp-set-connection-property v "process-buffer" buffer) |
| 1083 | (ignore-errors | 1083 | |
| 1084 | (set-process-query-on-exit-flag p t) | 1084 | (with-current-buffer (tramp-get-connection-buffer v) |
| 1085 | (set-marker (process-mark p) (point))) | 1085 | (unwind-protect |
| 1086 | ;; Return process. | 1086 | ;; We catch this event. Otherwise, `make-process' |
| 1087 | p)))) | 1087 | ;; could be called on the local host. |
| 1088 | 1088 | (save-excursion | |
| 1089 | ;; Save exit. | 1089 | (save-restriction |
| 1090 | (if (string-match-p tramp-temp-buffer-name (buffer-name)) | 1090 | ;; Activate narrowing in order to save BUFFER |
| 1091 | (ignore-errors | 1091 | ;; contents. Clear also the modification time; |
| 1092 | (set-process-buffer (tramp-get-connection-process v) nil) | 1092 | ;; otherwise we might be interrupted by |
| 1093 | (kill-buffer (current-buffer))) | 1093 | ;; `verify-visited-file-modtime'. |
| 1094 | (set-buffer-modified-p bmp)) | 1094 | (let ((buffer-undo-list t) |
| 1095 | (tramp-flush-connection-property v "process-name") | 1095 | (buffer-read-only nil) |
| 1096 | (tramp-flush-connection-property v "process-buffer")))))) | 1096 | (mark (point))) |
| 1097 | (clear-visited-file-modtime) | ||
| 1098 | (narrow-to-region (point-max) (point-max)) | ||
| 1099 | ;; We call `tramp-adb-maybe-open-connection', in | ||
| 1100 | ;; order to cleanup the prompt afterwards. | ||
| 1101 | (tramp-adb-maybe-open-connection v) | ||
| 1102 | (widen) | ||
| 1103 | (delete-region mark (point)) | ||
| 1104 | (narrow-to-region (point-max) (point-max)) | ||
| 1105 | ;; Send the command. | ||
| 1106 | (let ((tramp-adb-prompt (regexp-quote command))) | ||
| 1107 | (tramp-adb-send-command v command)) | ||
| 1108 | (let ((p (tramp-get-connection-process v))) | ||
| 1109 | ;; Stop process if indicated. | ||
| 1110 | (when stop | ||
| 1111 | (stop-process p)) | ||
| 1112 | ;; Set sentinel and filter. | ||
| 1113 | (when sentinel | ||
| 1114 | (set-process-sentinel p sentinel)) | ||
| 1115 | (when filter | ||
| 1116 | (set-process-filter p filter)) | ||
| 1117 | ;; Set query flag and process marker for this | ||
| 1118 | ;; process. We ignore errors, because the | ||
| 1119 | ;; process could have finished already. | ||
| 1120 | (ignore-errors | ||
| 1121 | (set-process-query-on-exit-flag p (null noquery)) | ||
| 1122 | (set-marker (process-mark p) (point))) | ||
| 1123 | ;; Return process. | ||
| 1124 | p)))) | ||
| 1125 | |||
| 1126 | ;; Save exit. | ||
| 1127 | (if (string-match-p tramp-temp-buffer-name (buffer-name)) | ||
| 1128 | (ignore-errors | ||
| 1129 | (set-process-buffer (tramp-get-connection-process v) nil) | ||
| 1130 | (kill-buffer (current-buffer))) | ||
| 1131 | (set-buffer-modified-p bmp)) | ||
| 1132 | (tramp-flush-connection-property v "process-name") | ||
| 1133 | (tramp-flush-connection-property v "process-buffer")))))))) | ||
| 1097 | 1134 | ||
| 1098 | (defun tramp-adb-handle-exec-path () | 1135 | (defun tramp-adb-handle-exec-path () |
| 1099 | "Like `exec-path' for Tramp files." | 1136 | "Like `exec-path' for Tramp files." |