GNU Readline Library. Node: Completion Variables
Completion Functions
Custom Completers
A Short Completion Example
2.5.3: Completion Variables
- Variable: Function * rl_completion_entry_function
-
A pointer to the generator function for
completion_matches ()
.
NULL
means to use filename_entry_function ()
, the default
filename completer.
- Variable: CPPFunction * rl_attempted_completion_function
-
A pointer to an alternative function to create matches.
The function is called with text, start, and end.
start and end are indices in
rl_line_buffer
saying
what the boundaries of text are. If this function exists and
returns NULL
, or if this variable is set to NULL
, then
rl_complete ()
will call the value of
rl_completion_entry_function
to generate matches, otherwise the
array of strings returned will be used.
- Variable: CPFunction * rl_filename_quoting_function
-
A pointer to a function that will quote a filename in an application-
specific fashion. This is called if filename completion is being
attempted and one of the characters in
rl_filename_quote_characters
appears in a completed filename. The function is called with
text, match_type, and quote_pointer. The text
is the filename to be quoted. The match_type is either
SINGLE_MATCH
, if there is only one completion match, or
MULT_MATCH
. Some functions use this to decide whether or not to
insert a closing quote character. The quote_pointer is a pointer
to any opening quote character the user typed. Some functions choose
to reset this character.
- Variable: CPFunction * rl_filename_dequoting_function
-
A pointer to a function that will remove application-specific quoting
characters from a filename before completion is attempted, so those
characters do not interfere with matching the text against names in
the filesystem. It is called with text, the text of the word
to be dequoted, and quote_char, which is the quoting character
that delimits the filename (usually `
'
' or `"
'). If
quote_char is zero, the filename was not in an embedded string.
- Variable: Function * rl_char_is_quoted_p
-
A pointer to a function to call that determines whether or not a specific
character in the line buffer is quoted, according to whatever quoting
mechanism the program calling readline uses. The function is called with
two arguments: text, the text of the line, and index, the
index of the character in the line. It is used to decide whether a
character found in
rl_completer_word_break_characters
should be
used to break words for the completer.
- Variable: int rl_completion_query_items
-
Up to this many items will be displayed in response to a
possible-completions call. After that, we ask the user if she is sure
she wants to see them all. The default value is 100.
- Variable: char * rl_basic_word_break_characters
-
The basic list of characters that signal a break between words for the
completer routine. The default value of this variable is the characters
which break words for completion in Bash, i.e.,
" \t\n\"\\'`@$><=;|&{("
.
- Variable: char * rl_basic_quote_characters
-
List of quote characters which can cause a word break.
- Variable: char * rl_completer_word_break_characters
-
The list of characters that signal a break between words for
rl_complete_internal ()
. The default list is the value of
rl_basic_word_break_characters
.
- Variable: char * rl_completer_quote_characters
-
List of characters which can be used to quote a substring of the line.
Completion occurs on the entire substring, and within the substring
rl_completer_word_break_characters
are treated as any other character,
unless they also appear within this list.
- Variable: char * rl_filename_quote_characters
-
A list of characters that cause a filename to be quoted by the completer
when they appear in a completed filename. The default is the null string.
- Variable: char * rl_special_prefixes
-
The list of characters that are word break characters, but should be
left in text when it is passed to the completion function.
Programs can use this to help determine what kind of completing to do.
For instance, Bash sets this variable to "$@" so that it can complete
shell variables and hostnames.
- Variable: int rl_completion_append_character
-
When a single completion alternative matches at the end of the command
line, this character is appended to the inserted completion text. The
default is a space character (`
'). Setting this to the null
character (`\0
') prevents anything being appended automatically.
This can be changed in custom completion functions to
provide the ``most sensible word separator character'' according to
an application-specific command line syntax specification.
- Variable: int rl_ignore_completion_duplicates
-
If non-zero, then disallow duplicates in the matches. Default is 1.
- Variable: int rl_filename_completion_desired
-
Non-zero means that the results of the matches are to be treated as
filenames. This is always zero on entry, and can only be changed
within a completion entry generator function. If it is set to a non-zero
value, directory names have a slash appended and Readline attempts to
quote completed filenames if they contain any embedded word break
characters.
- Variable: int rl_filename_quoting_desired
-
Non-zero means that the results of the matches are to be quoted using
double quotes (or an application-specific quoting mechanism) if the
completed filename contains any characters in
rl_filename_quote_chars
. This is always non-zero
on entry, and can only be changed within a completion entry generator
function. The quoting is effected via a call to the function pointed to
by rl_filename_quoting_function
.
- Variable: int rl_inhibit_completion
-
If this variable is non-zero, completion is inhibit<ed. The completion
character will be inserted as any other bound to
self-insert
.
- Variable: Function * rl_ignore_some_completions_function
-
This function, if defined, is called by the completer when real filename
completion is done, after all the matching names have been generated.
It is passed a
NULL
terminated array of matches.
The first element (matches[0]
) is the
maximal substring common to all matches. This function can
re-arrange the list of matches as required, but each element deleted
from the array must be freed.
- Variable: Function * rl_directory_completion_hook
-
This function, if defined, is allowed to modify the directory portion
of filenames Readline completes. It is called with the address of a
string (the current directory name) as an argument. It could be used
to expand symbolic links or shell variables in pathnames.
Completion Functions
Custom Completers
A Short Completion Example