Skip to content

Commit ed168f0

Browse files
committed
docs(api-and-naming): document _comp_xfunc considerations
#539 (reply in thread)
1 parent 53549b0 commit ed168f0

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

doc/api-and-naming.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
Due to its nature, bash-completion adds a number of functions and variables in
44
the shell's environment.
55

6-
| | `bash_completion` | `completions/*` |
7-
| :----------------------------- | :------------------ | :----------------------------------------------------- |
8-
| public configuration variables | `BASH_COMPLETION_*` | `BASH_COMPLETION_CMD_${Command^^}_${Config^^}` |
9-
| non-local internal variables | `_comp__*` | `_comp_cmd_${Command}__${Data}` |
10-
| public/exported functions | `_comp_*` | `_comp_cmd_${Command}` (functions for `complete -F`) |
11-
| private/internal functions | `_comp__*` | `_comp_cmd_${Command}__${Utility}` (utility functions) |
6+
| | `bash_completion` | `completions/*` |
7+
| :----------------------------- | :------------------ | :------------------------------------------------------------------------- |
8+
| public configuration variables | `BASH_COMPLETION_*` | `BASH_COMPLETION_CMD_${Command^^}_${Config^^}` |
9+
| non-local internal variables | `_comp__*` | `_comp_cmd_${Command}__${Data}` |
10+
| public/exported functions | `_comp_*` | `_comp_cmd_${Command}` (functions for `complete -F`) |
11+
| | | `_comp_xfunc_${Command}_${Utility}` (functions for use with `_comp_xfunc`) |
12+
| private/internal functions | `_comp__*` | `_comp_cmd_${Command}__${Utility}` (utility functions) |
1213

1314
`${Command}` refers to a command name (with characters not allowed in POSIX
1415
function or variable names replaced by an underscore), `${Config}` the name of
@@ -31,6 +32,11 @@ Variables and functions whose name contains a double underscore (`__`) anywhere
3132
in their name are private implementation details, not part of the stable API,
3233
and not intended to be used outside of their defining context.
3334

35+
Functions with names prefixed with `_comp_xfunc_` are intended to be used
36+
through the `_comp_xfunc` function from files other than the one they are
37+
defined in. From the same file they can be used directly using their complete
38+
name.
39+
3440
Function names start with an underscore in order to avoid them being
3541
included in completions of command names. (Except naturally when a command
3642
starting with an underscore is being completed.) The underscore prefix does

0 commit comments

Comments
 (0)