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)
This commit is contained in:
parent
a94ac604d8
commit
9fe788a1fa
1 changed files with 112 additions and 75 deletions
|
|
@ -144,7 +144,7 @@ It is used for TCP/IP devices."
|
|||
(make-directory . tramp-adb-handle-make-directory)
|
||||
(make-directory-internal . ignore)
|
||||
(make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
|
||||
(make-process . ignore)
|
||||
(make-process . tramp-adb-handle-make-process)
|
||||
(make-symbolic-link . tramp-handle-make-symbolic-link)
|
||||
(process-file . tramp-adb-handle-process-file)
|
||||
(rename-file . tramp-adb-handle-rename-file)
|
||||
|
|
@ -154,7 +154,7 @@ It is used for TCP/IP devices."
|
|||
(set-file-times . tramp-adb-handle-set-file-times)
|
||||
(set-visited-file-modtime . tramp-handle-set-visited-file-modtime)
|
||||
(shell-command . tramp-adb-handle-shell-command)
|
||||
(start-file-process . tramp-adb-handle-start-file-process)
|
||||
(start-file-process . tramp-handle-start-file-process)
|
||||
(substitute-in-file-name . tramp-handle-substitute-in-file-name)
|
||||
(temporary-file-directory . tramp-handle-temporary-file-directory)
|
||||
(tramp-set-file-uid-gid . ignore)
|
||||
|
|
@ -1017,83 +1017,120 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
|
|||
;; 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.
|
||||
(defun tramp-adb-handle-start-file-process (name buffer program &rest args)
|
||||
"Like `start-file-process' for Tramp files."
|
||||
(with-parsed-tramp-file-name default-directory nil
|
||||
;; When PROGRAM is nil, we should provide a tty. This is not
|
||||
;; possible here.
|
||||
(unless (stringp program)
|
||||
(tramp-error v 'file-error "PROGRAM must be a string"))
|
||||
(defun tramp-adb-handle-make-process (&rest args)
|
||||
"Like `make-process' for Tramp files."
|
||||
(when args
|
||||
(with-parsed-tramp-file-name (expand-file-name default-directory) nil
|
||||
(let ((name (plist-get args :name))
|
||||
(buffer (plist-get args :buffer))
|
||||
(command (plist-get args :command))
|
||||
(coding (plist-get args :coding))
|
||||
(noquery (plist-get args :noquery))
|
||||
(stop (plist-get args :stop))
|
||||
(connection-type (plist-get args :connection-type))
|
||||
(filter (plist-get args :filter))
|
||||
(sentinel (plist-get args :sentinel))
|
||||
(stderr (plist-get args :stderr)))
|
||||
(unless (stringp name)
|
||||
(signal 'wrong-type-argument (list 'stringp name)))
|
||||
(unless (or (null buffer) (bufferp buffer) (stringp buffer))
|
||||
(signal 'wrong-type-argument (list 'stringp buffer)))
|
||||
(unless (consp command)
|
||||
(signal 'wrong-type-argument (list 'consp command)))
|
||||
(unless (or (null coding)
|
||||
(and (symbolp coding) (memq coding coding-system-list))
|
||||
(and (consp coding)
|
||||
(memq (car coding) coding-system-list)
|
||||
(memq (cdr coding) coding-system-list)))
|
||||
(signal 'wrong-type-argument (list 'symbolp coding)))
|
||||
(unless (or (null connection-type) (memq connection-type '(pipe pty)))
|
||||
(signal 'wrong-type-argument (list 'symbolp connection-type)))
|
||||
(unless (or (null filter) (functionp filter))
|
||||
(signal 'wrong-type-argument (list 'functionp filter)))
|
||||
(unless (or (null sentinel) (functionp sentinel))
|
||||
(signal 'wrong-type-argument (list 'functionp sentinel)))
|
||||
(unless (or (null stderr) (bufferp stderr) (stringp stderr))
|
||||
(signal 'wrong-type-argument (list 'stringp stderr)))
|
||||
|
||||
(let* ((buffer
|
||||
(if buffer
|
||||
(get-buffer-create buffer)
|
||||
;; BUFFER can be nil. We use a temporary buffer.
|
||||
(generate-new-buffer tramp-temp-buffer-name)))
|
||||
(command
|
||||
(format "cd %s; %s"
|
||||
(tramp-shell-quote-argument localname)
|
||||
(mapconcat 'tramp-shell-quote-argument
|
||||
(cons program args) " ")))
|
||||
(tramp-process-connection-type
|
||||
(or (null program) tramp-process-connection-type))
|
||||
(bmp (and (buffer-live-p buffer) (buffer-modified-p buffer)))
|
||||
(name1 name)
|
||||
(i 0)
|
||||
;; We do not want to run timers.
|
||||
timer-list timer-idle-list)
|
||||
(let* ((buffer
|
||||
(if buffer
|
||||
(get-buffer-create buffer)
|
||||
;; BUFFER can be nil. We use a temporary buffer.
|
||||
(generate-new-buffer tramp-temp-buffer-name)))
|
||||
(program (car command))
|
||||
(args (cdr command))
|
||||
(command
|
||||
(format "cd %s; %s"
|
||||
(tramp-shell-quote-argument localname)
|
||||
(mapconcat 'tramp-shell-quote-argument
|
||||
(cons program args) " ")))
|
||||
(tramp-process-connection-type
|
||||
(or (null program) tramp-process-connection-type))
|
||||
(bmp (and (buffer-live-p buffer) (buffer-modified-p buffer)))
|
||||
(name1 name)
|
||||
(i 0)
|
||||
;; We do not want to run timers.
|
||||
timer-list timer-idle-list)
|
||||
|
||||
(while (get-process name1)
|
||||
;; NAME must be unique as process name.
|
||||
(setq i (1+ i)
|
||||
name1 (format "%s<%d>" name i)))
|
||||
(setq name name1)
|
||||
;; Set the new process properties.
|
||||
(tramp-set-connection-property v "process-name" name)
|
||||
(tramp-set-connection-property v "process-buffer" buffer)
|
||||
(while (get-process name1)
|
||||
;; NAME must be unique as process name.
|
||||
(setq i (1+ i)
|
||||
name1 (format "%s<%d>" name i)))
|
||||
(setq name name1)
|
||||
;; Set the new process properties.
|
||||
(tramp-set-connection-property v "process-name" name)
|
||||
(tramp-set-connection-property v "process-buffer" buffer)
|
||||
|
||||
(with-current-buffer (tramp-get-connection-buffer v)
|
||||
(unwind-protect
|
||||
;; We catch this event. Otherwise, `start-process' could
|
||||
;; be called on the local host.
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
;; Activate narrowing in order to save BUFFER
|
||||
;; contents. Clear also the modification time;
|
||||
;; otherwise we might be interrupted by
|
||||
;; `verify-visited-file-modtime'.
|
||||
(let ((buffer-undo-list t)
|
||||
(buffer-read-only nil)
|
||||
(mark (point)))
|
||||
(clear-visited-file-modtime)
|
||||
(narrow-to-region (point-max) (point-max))
|
||||
;; We call `tramp-adb-maybe-open-connection', in
|
||||
;; order to cleanup the prompt afterwards.
|
||||
(tramp-adb-maybe-open-connection v)
|
||||
(widen)
|
||||
(delete-region mark (point))
|
||||
(narrow-to-region (point-max) (point-max))
|
||||
;; Send the command.
|
||||
(let ((tramp-adb-prompt (regexp-quote command)))
|
||||
(tramp-adb-send-command v command))
|
||||
(let ((p (tramp-get-connection-process v)))
|
||||
;; Set query flag and process marker for this
|
||||
;; process. We ignore errors, because the process
|
||||
;; could have finished already.
|
||||
(ignore-errors
|
||||
(set-process-query-on-exit-flag p t)
|
||||
(set-marker (process-mark p) (point)))
|
||||
;; Return process.
|
||||
p))))
|
||||
(with-current-buffer (tramp-get-connection-buffer v)
|
||||
(unwind-protect
|
||||
;; We catch this event. Otherwise, `make-process'
|
||||
;; could be called on the local host.
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
;; Activate narrowing in order to save BUFFER
|
||||
;; contents. Clear also the modification time;
|
||||
;; otherwise we might be interrupted by
|
||||
;; `verify-visited-file-modtime'.
|
||||
(let ((buffer-undo-list t)
|
||||
(buffer-read-only nil)
|
||||
(mark (point)))
|
||||
(clear-visited-file-modtime)
|
||||
(narrow-to-region (point-max) (point-max))
|
||||
;; We call `tramp-adb-maybe-open-connection', in
|
||||
;; order to cleanup the prompt afterwards.
|
||||
(tramp-adb-maybe-open-connection v)
|
||||
(widen)
|
||||
(delete-region mark (point))
|
||||
(narrow-to-region (point-max) (point-max))
|
||||
;; Send the command.
|
||||
(let ((tramp-adb-prompt (regexp-quote command)))
|
||||
(tramp-adb-send-command v command))
|
||||
(let ((p (tramp-get-connection-process v)))
|
||||
;; Stop process if indicated.
|
||||
(when stop
|
||||
(stop-process p))
|
||||
;; Set sentinel and filter.
|
||||
(when sentinel
|
||||
(set-process-sentinel p sentinel))
|
||||
(when filter
|
||||
(set-process-filter p filter))
|
||||
;; Set query flag and process marker for this
|
||||
;; process. We ignore errors, because the
|
||||
;; process could have finished already.
|
||||
(ignore-errors
|
||||
(set-process-query-on-exit-flag p (null noquery))
|
||||
(set-marker (process-mark p) (point)))
|
||||
;; Return process.
|
||||
p))))
|
||||
|
||||
;; Save exit.
|
||||
(if (string-match-p tramp-temp-buffer-name (buffer-name))
|
||||
(ignore-errors
|
||||
(set-process-buffer (tramp-get-connection-process v) nil)
|
||||
(kill-buffer (current-buffer)))
|
||||
(set-buffer-modified-p bmp))
|
||||
(tramp-flush-connection-property v "process-name")
|
||||
(tramp-flush-connection-property v "process-buffer"))))))
|
||||
;; Save exit.
|
||||
(if (string-match-p tramp-temp-buffer-name (buffer-name))
|
||||
(ignore-errors
|
||||
(set-process-buffer (tramp-get-connection-process v) nil)
|
||||
(kill-buffer (current-buffer)))
|
||||
(set-buffer-modified-p bmp))
|
||||
(tramp-flush-connection-property v "process-name")
|
||||
(tramp-flush-connection-property v "process-buffer"))))))))
|
||||
|
||||
(defun tramp-adb-handle-exec-path ()
|
||||
"Like `exec-path' for Tramp files."
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue