Next: call-process-shell-command, Previous: call-process—a primitive, Up: Creating Synchronous Subprocesses [Index]
This function sends the text from START to END as standard input to a process running PROGRAM. It deletes the text sent if DELETE is non-‘nil’; this is useful when DESTINATION is ‘t’, to insert the output in the current buffer in place of the input.
The arguments DESTINATION and DISPLAY control what to do with the output from the subprocess, and whether to update the display as it comes in. For details, see the description of ‘call-process’, above. If DESTINATION is the integer 0, ‘call-process-region’ discards the output and returns ‘nil’ immediately, without waiting for the subprocess to finish.
The remaining arguments, ARGS, are strings that specify command line arguments for the program.
The return value of ‘call-process-region’ is just like that of ‘call-process’: ‘nil’ if you told it to return without waiting; otherwise, a number or string which indicates how the subprocess terminated.
In the following example, we use call-process-region
to run the cat
utility, with standard input being the first five characters in buffer ‘foo’
(the word ‘input’). cat
copies its standard input into its standard output.
Since the argument DESTINATION is ‘t’, this output is inserted in the current
buffer.
---------- Buffer: foo ---------- input★ ---------- Buffer: foo ---------- (call-process-region 1 6 "cat" nil t) ⇒ 0 ---------- Buffer: foo ---------- inputinput★ ---------- Buffer: foo ----------