Function: tramp-skeleton-process-file
tramp-skeleton-process-file is a macro defined in tramp.el.gz.
Signature
(tramp-skeleton-process-file PROGRAM &optional INFILE DESTINATION DISPLAY ARGS &rest BODY)
Documentation
Skeleton for tramp-*-handle-process-file.
BODY is the backend specific code.
Source Code
;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
(defmacro tramp-skeleton-process-file
(_program &optional infile destination _display _args &rest body)
"Skeleton for `tramp-*-handle-process-file'.
BODY is the backend specific code."
(declare (indent 5) (debug t))
`(with-parsed-tramp-file-name (expand-file-name default-directory) nil
;; The implementation is not complete yet.
(when (and (numberp ,destination) (zerop ,destination))
(tramp-error
v 'file-error "Implementation does not handle immediate return"))
(let (command input tmpinput stderr tmpstderr outbuf ret)
;; Determine input.
(if (null ,infile)
(setq input (tramp-get-remote-null-device v))
(setq ,infile (file-name-unquote (expand-file-name ,infile)))
(if (tramp-equal-remote default-directory ,infile)
;; INFILE is on the same remote host.
(setq input (tramp-unquote-file-local-name ,infile))
;; ,INFILE must be copied to remote host.
(setq input (tramp-make-tramp-temp-file v)
tmpinput (tramp-make-tramp-file-name v input))
(copy-file ,infile tmpinput t)))
;; Determine output.
(cond
;; Just a buffer.
((bufferp ,destination)
(setq outbuf ,destination))
;; A buffer name.
((stringp ,destination)
(setq outbuf (get-buffer-create ,destination)))
;; (REAL-,DESTINATION ERROR-,DESTINATION)
((consp ,destination)
;; output.
(cond
((bufferp (car ,destination))
(setq outbuf (car ,destination)))
((stringp (car ,destination))
(setq outbuf (get-buffer-create (car ,destination))))
((car ,destination)
(setq outbuf (current-buffer))))
;; stderr.
(cond
((stringp (cadr ,destination))
(setcar (cdr ,destination) (expand-file-name (cadr ,destination)))
(if (tramp-equal-remote default-directory (cadr ,destination))
;; stderr is on the same remote host.
(setq stderr (tramp-unquote-file-local-name (cadr ,destination)))
;; stderr must be copied to remote host. The temporary
;; file must be deleted after execution.
(setq stderr (tramp-make-tramp-temp-file v)
tmpstderr (tramp-make-tramp-file-name v stderr))))
;; stderr to be discarded.
((null (cadr ,destination))
(setq stderr (tramp-get-remote-null-device v)))
((eq (cadr ,destination) tramp-cache-undefined)
;; stderr is not implemented.
(tramp-warning v "%s" "STDERR not supported"))))
;; t
(,destination
(setq outbuf (current-buffer))))
,@body
;; Provide error file.
(when tmpstderr (rename-file tmpstderr (cadr ,destination) t))
;; Cleanup. We remove all file cache values for the connection,
;; because the remote process could have changed them.
(when tmpinput (delete-file tmpinput))
(when process-file-side-effects
(tramp-flush-directory-properties v "/"))
;; Return exit status.
(if (equal ret -1)
(keyboard-quit)
ret))))