Next: User Name Completion, Previous: Unique File Names, Up: File Names [Contents][Index]
This section describes low-level subroutines for completing a file name. For other completion functions, see Completion.
This function returns a list of all possible completions for files whose name starts with partial-filename in directory directory. The order of the completions is the order of the files in the directory, which is unpredictable and conveys no useful information.
The argument partial-filename must be a file name containing no directory part and no slash. The current buffer’s default directory is prepended to directory, if directory is not absolute.
File names which end with any member of completion-ignored-extensions
are not considered as possible completions for partial-filename unless
there is no other possible completion. completion-ignored-extensions
is not applied to the names of directories.
In the following example, suppose that the current default directory, ~rms/lewis, has five files whose names begin with ‘f’: foo, file~, file.c, file.c.~1~, and file.c.~2~.
(file-name-all-completions "f" "") ⇒ ("foo" "file~" "file.c.~2~" "file.c.~1~" "file.c")
(file-name-all-completions "fo" "") ⇒ ("foo")
This function completes the file name partial-filename in directory directory. It returns the longest prefix common to all file names in directory directory that start with partial-filename.
If only one match exists and partial-filename matches it exactly, the
function returns t
. The function returns nil
if directory
directory contains no name starting with partial-filename.
File names which end with any member of completion-ignored-extensions
are not considered as possible completions for partial-filename unless
there is no other possible completion. completion-ignored-extensions
is not applied to the names of directories.
In the following example, suppose that the current default directory has five files whose names begin with ‘f’: foo, file~, file.c, file.c.~1~, and file.c.~2~.
(file-name-completion "fi" "") ⇒ "file"
(file-name-completion "file.c.~1" "") ⇒ "file.c.~1~"
(file-name-completion "file.c.~1~" "") ⇒ t
(file-name-completion "file.c.~3" "") ⇒ nil
file-name-completion
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 or when a buffer showing all
possible completions is displayed.
A typical value might look like this:
completion-ignored-extensions ⇒ (".o" ".elc" "~" ".dvi")
Next: User Name Completion, Previous: Unique File Names, Up: File Names [Contents][Index]