summaryrefslogtreecommitdiff
path: root/devdocs/elisp/subprocess-creation.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/subprocess-creation.html
new repository
Diffstat (limited to 'devdocs/elisp/subprocess-creation.html')
-rw-r--r--devdocs/elisp/subprocess-creation.html18
1 files changed, 18 insertions, 0 deletions
diff --git a/devdocs/elisp/subprocess-creation.html b/devdocs/elisp/subprocess-creation.html
new file mode 100644
index 00000000..d4a3d5db
--- /dev/null
+++ b/devdocs/elisp/subprocess-creation.html
@@ -0,0 +1,18 @@
+ <h3 class="section">Functions that Create Subprocesses</h3> <p>There are three primitives that create a new subprocess in which to run a program. One of them, <code>make-process</code>, creates an asynchronous process and returns a process object (see <a href="asynchronous-processes">Asynchronous Processes</a>). The other two, <code>call-process</code> and <code>call-process-region</code>, create a synchronous process and do not return a process object (see <a href="synchronous-processes">Synchronous Processes</a>). There are various higher-level functions that make use of these primitives to run particular types of process. </p> <p>Synchronous and asynchronous processes are explained in the following sections. Since the three functions are all called in a similar fashion, their common arguments are described here. </p> <p>In all cases, the functions specify the program to be run. An error is signaled if the file is not found or cannot be executed. If the file name is relative, the variable <code>exec-path</code> contains a list of directories to search. Emacs initializes <code>exec-path</code> when it starts up, based on the value of the environment variable <code>PATH</code>. The standard file name constructs, ‘<samp>~</samp>’, ‘<samp>.</samp>’, and ‘<samp>..</samp>’, are interpreted as usual in <code>exec-path</code>, but environment variable substitutions (‘<samp>$HOME</samp>’, etc.) are not recognized; use <code>substitute-in-file-name</code> to perform them (see <a href="file-name-expansion">File Name Expansion</a>). <code>nil</code> in this list refers to <code>default-directory</code>. </p> <p>Executing a program can also try adding suffixes to the specified name: </p> <dl> <dt id="exec-suffixes">User Option: <strong>exec-suffixes</strong>
+</dt> <dd><p>This variable is a list of suffixes (strings) to try adding to the specified program file name. The list should include <code>""</code> if you want the name to be tried exactly as specified. The default value is system-dependent. </p></dd>
+</dl> <p><strong>Please note:</strong> The argument <var>program</var> contains only the name of the program file; it may not contain any command-line arguments. You must use a separate argument, <var>args</var>, to provide those, as described below. </p> <p>Each of the subprocess-creating functions has a <var>buffer-or-name</var> argument that specifies where the output from the program will go. It should be a buffer or a buffer name; if it is a buffer name, that will create the buffer if it does not already exist. It can also be <code>nil</code>, which says to discard the output, unless a custom filter function handles it. (See <a href="filter-functions">Filter Functions</a>, and <a href="read-and-print">Read and Print</a>.) Normally, you should avoid having multiple processes send output to the same buffer because their output would be intermixed randomly. For synchronous processes, you can send the output to a file instead of a buffer (and the corresponding argument is therefore more appropriately called <var>destination</var>). By default, both standard output and standard error streams go to the same destination, but all the 3 primitives allow optionally to direct the standard error stream to a different destination. </p> <p>All three of the subprocess-creating functions allow to specify command-line arguments for the process to run. For <code>call-process</code> and <code>call-process-region</code>, these come in the form of a <code>&amp;rest</code> argument, <var>args</var>. For <code>make-process</code>, both the program to run and its command-line arguments are specified as a list of strings. The command-line arguments must all be strings, and they are supplied to the program as separate argument strings. Wildcard characters and other shell constructs have no special meanings in these strings, since the strings are passed directly to the specified program. </p> <p>The subprocess inherits its environment from Emacs, but you can specify overrides for it with <code>process-environment</code>. See <a href="system-environment">System Environment</a>. The subprocess gets its current directory from the value of <code>default-directory</code>. </p> <dl> <dt id="exec-directory">Variable: <strong>exec-directory</strong>
+</dt> <dd>
+ <p>The value of this variable is a string, the name of a directory that contains programs that come with GNU Emacs and are intended for Emacs to invoke. The program <code>movemail</code> is an example of such a program; Rmail uses it to fetch new mail from an inbox. </p>
+</dd>
+</dl> <dl> <dt id="exec-path">User Option: <strong>exec-path</strong>
+</dt> <dd>
+<p>The value of this variable is a list of directories to search for programs to run in subprocesses. Each element is either the name of a directory (i.e., a string), or <code>nil</code>, which stands for the default directory (which is the value of <code>default-directory</code>). See <a href="locating-files">executable-find</a>, for the details of this search. </p> <p>The value of <code>exec-path</code> is used by <code>call-process</code> and <code>start-process</code> when the <var>program</var> argument is not an absolute file name. </p> <p>Generally, you should not modify <code>exec-path</code> directly. Instead, ensure that your <code>PATH</code> environment variable is set appropriately before starting Emacs. Trying to modify <code>exec-path</code> independently of <code>PATH</code> can lead to confusing results. </p>
+</dd>
+</dl> <dl> <dt id="exec-path">Function: <strong>exec-path</strong>
+</dt> <dd><p>This function is an extension of the variable <code>exec-path</code>. If <code>default-directory</code> indicates a remote directory, this function returns a list of directories used for searching programs on the respective remote host. In case of a local <code>default-directory</code>, the function returns just the value of the variable <code>exec-path</code>. </p></dd>
+</dl><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
+ <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Subprocess-Creation.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Subprocess-Creation.html</a>
+ </p>
+</div>