Function: process-file
process-file is a byte-compiled function defined in simple.el.gz.
Signature
(process-file PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS)
Documentation
Process files synchronously in a separate process that runs PROGRAM.
Similar to call-process, but may invoke a file name handler based on
default-directory. The current working directory of the
subprocess is default-directory.
If PROGRAM is a remote file name, it should be processed
by file-local-name before passing it to this function.
Handle file names in INFILE and BUFFER normally; this differs
from call-process, which does not support file name handlers
for INFILE and BUFFER. However, pass ARGS to the process
verbatim without file name handling, as call-process does.
Some file name handlers might not support all variants. For example, they might treat DISPLAY as nil regardless of the actual value passed.
Probably introduced at or before Emacs version 22.1.
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun process-file (program &optional infile buffer display &rest args)
"Process files synchronously in a separate process that runs PROGRAM.
Similar to `call-process', but may invoke a file name handler based on
`default-directory'. The current working directory of the
subprocess is `default-directory'.
If PROGRAM is a remote file name, it should be processed
by `file-local-name' before passing it to this function.
Handle file names in INFILE and BUFFER normally; this differs
from `call-process', which does not support file name handlers
for INFILE and BUFFER. However, pass ARGS to the process
verbatim without file name handling, as `call-process' does.
Some file name handlers might not support all variants. For
example, they might treat DISPLAY as nil regardless of the actual
value passed."
(let ((fh (find-file-name-handler default-directory 'process-file))
lc stderr-file)
(unwind-protect
(if fh (apply fh 'process-file program infile buffer display args)
(when infile (setq lc (file-local-copy infile)))
(setq stderr-file (when (and (consp buffer) (stringp (cadr buffer)))
(make-temp-file "emacs")))
(prog1
(apply 'call-process program
(or lc infile)
(if stderr-file (list (car buffer) stderr-file) buffer)
display args)
(when stderr-file (copy-file stderr-file (cadr buffer) t))))
(when stderr-file (delete-file stderr-file))
(when lc (delete-file lc)))))