Go forward to Completion Variables.
Go backward to How Completing Works.
Go up to Custom Completers.

Completion Functions
--------------------

   Here is the complete list of callable completion functions present in
Readline.

 - Function: int rl_complete_internal (int what_to_do)
     Complete the word at or before point.  WHAT_TO_DO says what to do
     with the completion.  A value of `?' means list the possible
     completions.  `TAB' means do standard completion.  `*' means
     insert all of the possible completions.  `!' means to display all
     of the possible completions, if there is more than one, as well as
     performing partial completion.

 - Function: int rl_complete (int ignore, int invoking_key)
     Complete the word at or before point.  You have supplied the
     function that does the initial simple matching selection algorithm
     (see `completion_matches ()' and `rl_completion_entry_function').
     The default is to do filename completion.  This calls
     `rl_complete_internal ()' with an argument depending on
     INVOKING_KEY.

 - Function: int rl_possible_completions (int count, int invoking_key))
     List the possible completions.  See description of `rl_complete
     ()'.  This calls `rl_complete_internal ()' with an argument of `?'.

 - Function: int rl_insert_completions (int count, int invoking_key))
     Insert the list of possible completions into the line, deleting the
     partially-completed word.  See description of `rl_complete ()'.
     This calls `rl_complete_internal ()' with an argument of `*'.

 - Function: char ** completion_matches (char *text, CPFunction
          *entry_func)
     Returns an array of `(char *)' which is a list of completions for
     TEXT.  If there are no completions, returns `(char **)NULL'.  The
     first entry in the returned array is the substitution for TEXT.
     The remaining entries are the possible completions.  The array is
     terminated with a `NULL' pointer.

     ENTRY_FUNC is a function of two args, and returns a `(char *)'.
     The first argument is TEXT.  The second is a state argument; it is
     zero on the first call, and non-zero on subsequent calls.
     ENTRY_FUNC returns a `NULL'  pointer to the caller when there are
     no more matches.

 - Function: char * filename_completion_function (char *text, int state)
     A generator function for filename completion in the general case.
     Note that completion in Bash is a little different because of all
     the pathnames that must be followed when looking up completions
     for a command.  The Bash source is a useful reference for writing
     custom completion functions.

 - Function: char * username_completion_function (char *text, int state)
     A completion generator for usernames.  TEXT contains a partial
     username preceded by a random character (usually `~').  As with all
     completion generators, STATE is zero on the first call and non-zero
     for subsequent calls.