summaryrefslogtreecommitdiff
path: root/devdocs/elisp/locating-files.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/elisp/locating-files.html')
-rw-r--r--devdocs/elisp/locating-files.html17
1 files changed, 17 insertions, 0 deletions
diff --git a/devdocs/elisp/locating-files.html b/devdocs/elisp/locating-files.html
new file mode 100644
index 00000000..b999493d
--- /dev/null
+++ b/devdocs/elisp/locating-files.html
@@ -0,0 +1,17 @@
+ <h4 class="subsection">Locating Files in Standard Places</h4> <p>This section explains how to search for a file in a list of directories (a <em>path</em>), or for an executable file in the standard list of executable file directories. </p> <p>To search for a user-specific configuration file, See <a href="standard-file-names">Standard File Names</a>, for the <code>locate-user-emacs-file</code> function. </p> <dl> <dt id="locate-file">Function: <strong>locate-file</strong> <em>filename path &amp;optional suffixes predicate</em>
+</dt> <dd>
+<p>This function searches for a file whose name is <var>filename</var> in a list of directories given by <var>path</var>, trying the suffixes in <var>suffixes</var>. If it finds such a file, it returns the file’s absolute file name (see <a href="relative-file-names">Relative File Names</a>); otherwise it returns <code>nil</code>. </p> <p>The optional argument <var>suffixes</var> gives the list of file-name suffixes to append to <var>filename</var> when searching. <code>locate-file</code> tries each possible directory with each of these suffixes. If <var>suffixes</var> is <code>nil</code>, or <code>("")</code>, then there are no suffixes, and <var>filename</var> is used only as-is. Typical values of <var>suffixes</var> are <code>exec-suffixes</code> (see <a href="subprocess-creation">Subprocess Creation</a>), <code>load-suffixes</code>, <code>load-file-rep-suffixes</code> and the return value of the function <code>get-load-suffixes</code> (see <a href="load-suffixes">Load Suffixes</a>). </p> <p>Typical values for <var>path</var> are <code>exec-path</code> (see <a href="subprocess-creation">Subprocess Creation</a>) when looking for executable programs, or <code>load-path</code> (see <a href="library-search">Library Search</a>) when looking for Lisp files. If <var>filename</var> is absolute, <var>path</var> has no effect, but the suffixes in <var>suffixes</var> are still tried. </p> <p>The optional argument <var>predicate</var>, if non-<code>nil</code>, specifies a predicate function for testing whether a candidate file is suitable. The predicate is passed the candidate file name as its single argument. If <var>predicate</var> is <code>nil</code> or omitted, <code>locate-file</code> uses <code>file-readable-p</code> as the predicate. See <a href="kinds-of-files">Kinds of Files</a>, for other useful predicates, e.g., <code>file-executable-p</code> and <code>file-directory-p</code>. </p> <p>This function will normally skip directories, so if you want it to find directories, make sure the <var>predicate</var> function returns <code>dir-ok</code> for them. For example: </p> <div class="example"> <pre class="example">(locate-file "html" '("/var/www" "/srv") nil
+ (lambda (f) (if (file-directory-p f) 'dir-ok)))
+</pre>
+</div> <p>For compatibility, <var>predicate</var> can also be one of the symbols <code>executable</code>, <code>readable</code>, <code>writable</code>, <code>exists</code>, or a list of one or more of these symbols. </p>
+</dd>
+</dl> <dl> <dt id="executable-find">Function: <strong>executable-find</strong> <em>program &amp;optional remote</em>
+</dt> <dd>
+<p>This function searches for the executable file of the named <var>program</var> and returns the absolute file name of the executable, including its file-name extensions, if any. It returns <code>nil</code> if the file is not found. The function searches in all the directories in <code>exec-path</code>, and tries all the file-name extensions in <code>exec-suffixes</code> (see <a href="subprocess-creation">Subprocess Creation</a>). </p> <p>If <var>remote</var> is non-<code>nil</code>, and <code>default-directory</code> is a remote directory, <var>program</var> is searched on the respective remote host. </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/Locating-Files.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Locating-Files.html</a>
+ </p>
+</div>