Function: tramp-process-actions
tramp-process-actions is a byte-compiled function defined in
tramp.el.gz.
Signature
(tramp-process-actions PROC VEC POS ACTIONS &optional TIMEOUT)
Documentation
Perform ACTIONS until success or TIMEOUT.
PROC and VEC indicate the remote connection to be used. POS, if set, is the starting point of the region to be deleted in the connection buffer.
ACTIONS is a list of (PATTERN ACTION). The PATTERN should be a symbol, a variable. The value of this variable gives the regular expression to search for. Note that the regexp must match at the end of the buffer, "\\'" is implicitly appended to it.
The ACTION should also be a symbol, but a function. When the corresponding PATTERN matches, the ACTION function is called.
An ACTION function has two arguments (PROC VEC). If it returns nil, nothing has been done, and the next action shall be called. A non-nil return value indicates that the process output has been consumed, and new output shall be retrieved, before starting to process all ACTIONs, again. The same happens after calling the last ACTION.
If an action determines, that all processing has been done (e.g.,
because the shell prompt has been detected), it shall throw a
result. The symbol ok means that all ACTIONs have been
performed successfully. Any other value means an error.
Source Code
;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
(defun tramp-process-actions (proc vec pos actions &optional timeout)
"Perform ACTIONS until success or TIMEOUT.
PROC and VEC indicate the remote connection to be used. POS, if
set, is the starting point of the region to be deleted in the
connection buffer.
ACTIONS is a list of (PATTERN ACTION). The PATTERN should be a
symbol, a variable. The value of this variable gives the regular
expression to search for. Note that the regexp must match at the
end of the buffer, \"\\'\" is implicitly appended to it.
The ACTION should also be a symbol, but a function. When the
corresponding PATTERN matches, the ACTION function is called.
An ACTION function has two arguments (PROC VEC). If it returns
nil, nothing has been done, and the next action shall be called.
A non-nil return value indicates that the process output has been
consumed, and new output shall be retrieved, before starting to
process all ACTIONs, again. The same happens after calling the
last ACTION.
If an action determines, that all processing has been done (e.g.,
because the shell prompt has been detected), it shall throw a
result. The symbol `ok' means that all ACTIONs have been
performed successfully. Any other value means an error."
;; Enable `auth-source', unless "emacs -Q" has been called. We must
;; use the "hop-vector" property in case we have several hops.
(tramp-set-connection-property
(tramp-get-connection-property
proc "hop-vector" (process-get proc 'tramp-vector))
" first-password-request" tramp-cache-read-persistent-data)
(save-restriction
(with-tramp-progress-reporter
proc 3 "Waiting for prompts from remote shell"
(let ((enable-recursive-minibuffers t)
exit)
(with-tramp-timeout (timeout (setq exit 'timeout))
(while (not exit)
(setq exit (catch 'tramp-action
(tramp-process-one-action proc vec actions)))))
(with-current-buffer (tramp-get-connection-buffer vec)
(widen)
(tramp-message vec 6 "\n%s" (buffer-string)))
(if (eq exit 'ok)
(ignore-errors
(when (functionp tramp-password-save-function)
(funcall tramp-password-save-function)
(setq tramp-password-save-function nil)))
;; Not successful.
(tramp-clear-passwd vec)
(delete-process proc)
(tramp-error-with-buffer
(tramp-get-connection-buffer vec) vec 'file-error
(cond
((eq exit 'permission-denied) "Permission denied")
((eq exit 'out-of-band-failed)
(format-message
"Copy failed, see buffer `%s' for details"
(tramp-get-connection-buffer vec)))
((eq exit 'process-died)
(substitute-command-keys
(concat
"Tramp failed to connect. If this happens repeatedly, try\n"
" `\\[tramp-cleanup-this-connection]'")))
((eq exit 'timeout)
(format-message
"Timeout reached, see buffer `%s' for details"
(tramp-get-connection-buffer vec)))
(t "Login failed")))))
(when (numberp pos)
(with-current-buffer (tramp-get-connection-buffer vec)
(let ((inhibit-read-only t)) (delete-region pos (point))))))))