Function: tramp-smb-handle-make-process
tramp-smb-handle-make-process is a byte-compiled function defined in
tramp-smb.el.gz.
Signature
(tramp-smb-handle-make-process &rest ARGS)
Documentation
Like make-process for Tramp files.
If method parameter tramp-direct-async and connection-local variable
tramp-direct-async-process are non-nil, an alternative implementation
will be used.
Source Code
;; Defined in /usr/src/emacs/lisp/net/tramp-smb.el.gz
;; 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-smb-handle-make-process (&rest args)
"Like `make-process' for Tramp files.
If method parameter `tramp-direct-async' and connection-local variable
`tramp-direct-async-process' are non-nil, an alternative implementation
will be used."
(if (tramp-direct-async-process-p args)
(apply #'tramp-handle-make-process args)
(tramp-skeleton-make-process args nil t
(let* ((command (string-join command " "))
;; STDERR can also be a file name.
(tmpstderr
(and stderr
(tramp-unquote-file-local-name
(if (stringp stderr)
stderr (tramp-make-tramp-temp-name v)))))
(remote-tmpstderr
(and tmpstderr (tramp-make-tramp-file-name v tmpstderr)))
(bmp (and (buffer-live-p buffer) (buffer-modified-p buffer)))
p)
(if tmpstderr
(setq command (format "%s 2>//%s%s" command host tmpstderr)))
;; Handle error buffer.
(when (bufferp stderr)
(make-empty-file remote-tmpstderr)
(with-current-buffer stderr
(setq buffer-read-only nil
default-directory (file-name-directory remote-tmpstderr))
(setq-local buffer-file-name remote-tmpstderr
auto-revert-notify-exclude-dir-regexp
"nothing-to-be-excluded"
create-lockfiles t)
(set-visited-file-modtime)
(set-buffer-modified-p nil)
(auto-save-mode -1)
(auto-save-visited-mode -1)
(auto-revert-tail-mode 1)))
(with-tramp-saved-connection-properties
v '(" process-name" " process-buffer")
(unwind-protect
(save-excursion
(save-restriction
;; Set the new process properties.
(tramp-set-connection-property v " process-name" name)
(tramp-set-connection-property v " process-buffer" buffer)
;; Activate narrowing in order to save BUFFER contents.
(with-current-buffer (tramp-get-connection-buffer v)
(let ((buffer-undo-list t))
(narrow-to-region (point-max) (point-max))
(tramp-smb-call-winexe v)
(tramp-message v 6 "%s" command)
(tramp-send-string v command)
(setq
tramp-smb-matching-line (rx bol (literal command) eol))
(add-hook 'comint-preoutput-filter-functions
#'tramp-smb-delete-matching-lines nil 'local)))
(setq p (tramp-get-connection-process v))
;; Set sentinel and filter.
(when sentinel
(set-process-sentinel p sentinel))
(when filter
(set-process-filter p filter))
(process-put p 'remote-command orig-command)
;; 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)))
;; We must flush them here already; otherwise
;; `delete-file' will fail.
(tramp-flush-connection-property v " process-name")
(tramp-flush-connection-property v " process-buffer")
;; Stop auto-revert. Delete stderr file.
(when (bufferp stderr)
(add-function
:after (process-sentinel p)
(lambda (_proc _msg)
(with-current-buffer stderr
(auto-revert-tail-mode -1)
(let ((remote-file-name-inhibit-locks t))
(revert-buffer nil 'noconfirm)))
(ignore-errors
(delete-file remote-tmpstderr)))))
;; Return value.
p))
;; Save exit.
;; FIXME: Does `tramp-get-connection-buffer' return the proper value?
(with-current-buffer (tramp-get-connection-buffer v)
(if (string-search tramp-temp-buffer-name (buffer-name))
(progn
(set-process-buffer (tramp-get-connection-process v) nil)
(kill-buffer (current-buffer)))
(set-buffer-modified-p bmp)))))))))