Function: file-name-completion

file-name-completion is a function defined in dired.c.

Signature

(file-name-completion FILE DIRECTORY &optional PREDICATE)

Documentation

Complete file name FILE in directory DIRECTORY.

Returns the longest string common to all file names in DIRECTORY that start with FILE. If there is only one and FILE matches it exactly, returns t. Returns nil if DIRECTORY contains no name starting with FILE.

If PREDICATE is non-nil, call PREDICATE with each possible completion (in absolute form) and ignore it if PREDICATE returns nil.

This function ignores some of the possible completions as determined by the variables completion-regexp-list and completion-ignored-extensions, which see. completion-regexp-list is matched against file and directory names relative to DIRECTORY.

Probably introduced at or before Emacs version 22.1.

Source Code

// Defined in /usr/src/emacs/src/dired.c
{
  Lisp_Object handler;
  directory = Fexpand_file_name (directory, Qnil);

  /* If the directory name has special constructs in it,
     call the corresponding file name handler.  */
  handler = Ffind_file_name_handler (directory, Qfile_name_completion);
  if (!NILP (handler))
    return call4 (handler, Qfile_name_completion, file, directory, predicate);

  /* If the file name has special constructs in it,
     call the corresponding file name handler.  */
  handler = Ffind_file_name_handler (file, Qfile_name_completion);
  if (!NILP (handler))
    return call4 (handler, Qfile_name_completion, file, directory, predicate);

  return file_name_completion (file, directory, 0, predicate);
}