diff options
Diffstat (limited to 'devdocs/elisp/file-name-completion.html')
| -rw-r--r-- | devdocs/elisp/file-name-completion.html | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/devdocs/elisp/file-name-completion.html b/devdocs/elisp/file-name-completion.html new file mode 100644 index 00000000..f2863c3d --- /dev/null +++ b/devdocs/elisp/file-name-completion.html @@ -0,0 +1,42 @@ + <h4 class="subsection">File Name Completion</h4> <p>This section describes low-level subroutines for completing a file name. For higher level functions, see <a href="reading-file-names">Reading File Names</a>. </p> <dl> <dt id="file-name-all-completions">Function: <strong>file-name-all-completions</strong> <em>partial-filename directory</em> +</dt> <dd> +<p>This function returns a list of all possible completions for a file whose name starts with <var>partial-filename</var> in directory <var>directory</var>. The order of the completions is the order of the files in the directory, which is unpredictable and conveys no useful information. </p> <p>The argument <var>partial-filename</var> must be a file name containing no directory part and no slash (or backslash on some systems). The current buffer’s default directory is prepended to <var>directory</var>, if <var>directory</var> is not absolute. </p> <p>In the following example, suppose that <samp>~rms/lewis</samp> is the current default directory, and has five files whose names begin with ‘<samp>f</samp>’: <samp>foo</samp>, <samp>file~</samp>, <samp>file.c</samp>, <samp>file.c.~1~</samp>, and <samp>file.c.~2~</samp>. </p> <div class="example"> <pre class="example">(file-name-all-completions "f" "") + ⇒ ("foo" "file~" "file.c.~2~" + "file.c.~1~" "file.c") +</pre> + +<pre class="example">(file-name-all-completions "fo" "") + ⇒ ("foo") +</pre> +</div> </dd> +</dl> <dl> <dt id="file-name-completion">Function: <strong>file-name-completion</strong> <em>filename directory &optional predicate</em> +</dt> <dd> +<p>This function completes the file name <var>filename</var> in directory <var>directory</var>. It returns the longest prefix common to all file names in directory <var>directory</var> that start with <var>filename</var>. If <var>predicate</var> is non-<code>nil</code> then it ignores possible completions that don’t satisfy <var>predicate</var>, after calling that function with one argument, the expanded absolute file name. </p> <p>If only one match exists and <var>filename</var> matches it exactly, the function returns <code>t</code>. The function returns <code>nil</code> if directory <var>directory</var> contains no name starting with <var>filename</var>. </p> <p>In the following example, suppose that the current default directory has five files whose names begin with ‘<samp>f</samp>’: <samp>foo</samp>, <samp>file~</samp>, <samp>file.c</samp>, <samp>file.c.~1~</samp>, and <samp>file.c.~2~</samp>. </p> <div class="example"> <pre class="example">(file-name-completion "fi" "") + ⇒ "file" +</pre> + +<pre class="example">(file-name-completion "file.c.~1" "") + ⇒ "file.c.~1~" +</pre> + +<pre class="example">(file-name-completion "file.c.~1~" "") + ⇒ t +</pre> + +<pre class="example">(file-name-completion "file.c.~3" "") + ⇒ nil +</pre> +</div> </dd> +</dl> <dl> <dt id="completion-ignored-extensions">User Option: <strong>completion-ignored-extensions</strong> +</dt> <dd> +<p><code>file-name-completion</code> usually ignores file names that end in any string in this list. It does not ignore them when all the possible completions end in one of these suffixes. This variable has no effect on <code>file-name-all-completions</code>. </p> <p>A typical value might look like this: </p> <div class="example"> <pre class="example">completion-ignored-extensions + ⇒ (".o" ".elc" "~" ".dvi") +</pre> +</div> <p>If an element of <code>completion-ignored-extensions</code> ends in a slash ‘<samp>/</samp>’, it signals a directory. The elements which do <em>not</em> end in a slash will never match a directory; thus, the above value will not filter out a directory named <samp>foo.elc</samp>. </p> +</dd> +</dl><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 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/File-Name-Completion.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/File-Name-Completion.html</a> + </p> +</div> |
