diff options
Diffstat (limited to 'Doc/Zsh/compsys.yo')
-rw-r--r-- | Doc/Zsh/compsys.yo | 111 |
1 files changed, 64 insertions, 47 deletions
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 572660de3..9d6cc10ce 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -41,15 +41,15 @@ directory (or multiple directories) of your own which should appear in your tt($fpath) variable so that the functions can be autoloaded. startmenu() -menu(Initialisation) +menu(Initialization) menu(Control Functions) menu(Completion Functions) endmenu() -texinode(Initialisation)(Control Functions)()(Completion System) -sect(Initialisation) +texinode(Initialization)(Control Functions)()(Completion System) +sect(Initialization) -The script tt(compinstall) can be run by a user to set up the completion +The function tt(compinstall) can be run by a user to set up the completion system for use. It will usually insert code into tt(.zshrc), although if that is not writable it will save it in another file and tell you that file's locations. Note that it is up to you to make sure that the lines @@ -59,13 +59,15 @@ So long as you keep them all together (including the comment lines at the start and finish), you can rerun tt(compinstall) and it will correctly locate and modify these lines. Note, however, that any code you add to this section by hand is likely to be lost if you rerun tt(compinstall). +The new code will take effect next time you start the shell, or run +tt(.zshrc) by hand. -You can run it as `tt(source )var(<path>)tt(/compinstall)' or -`tt(. )var(<path>)tt(/compinstall)', where var(<path>) is where the -completion functions are stored. It will ask you various questions about -how you would like completion set up. It is in two parts; the basic part +To run it, you will need to make sure it is in a directory mentioned in your +tt($fpath) parameter, and that it is autoloaded (`tt(autoload -U +compinstall)' is recommended). It will ask you various questions about how +you would like completion set up. It is in two parts; the basic part locates the completion files and decides where to put your personal -dumpfile, used to speed up initialisation after the first time. After +dumpfile, used to speed up initialization after the first time. After that, you will be asked if you wish to go on to the advanced set-up; if you answer tt(n), you can rerun tt(compinstall) later without having to re-enter any of the basic settings. @@ -73,36 +75,35 @@ re-enter any of the basic settings. You can abort the installation any time you are being prompted for information, and your tt(.zshrc) will not be altered at all. +After initialization all the builtin completion widgets such as +tt(expand-or-complete) will be redefined to use the new completion system. +Should you need to, you can still bind keys to the old functions by putting +a `tt(.)' in front, e.g. `tt(.expand-or-complete)'. + subsect(Use of compinit) This section describes the use of tt(compinit) to initialize completion for the current session when run directly by the user; if you have run tt(compinstall) it will be called automatically from your tt(.zshrc). -To initialise the system, the script tt(compinit) should be sourced with -`tt(source )var(<path>)tt(/compinit)' or -`tt(. )var(<path>)tt(/compinit)'. This will define a few utility functions, -arrange for all the necessary shell functions to be autoloaded, and will -then re-bind all keys that do completion to use the new system. +To initialize the system, the function tt(compinit) should be in a +directory mentioned in the tt($fpath) variable, and should be autoloaded +(`tt(autoload -U compinit)' is recommended). When run, it will define a +few utility functions, arrange for all the necessary shell functions to be +autoloaded, and will then re-bind all keys that do completion to use the +new system. To speed up the running of tt(compinit), it can be made to produce a dumped configuration which will be read in on future invocations. The easiest way -to do this is by adding the option tt(-d) whenever tt(compinit) is sourced. -In this case the dumped file will have the same name as the sourced file, -but with tt(.dump) appended to the end, or, if that is not writable by the -user, the file tt(.zcompdump) in the same directory as the startup files -(i.e. tt($ZDOTDIR) or tt($HOME)); alternatively, an explicit file name can -be given following the tt(-d). On the next call to tt(compinit -d), the -dumped file will be read instead. - -The other option accepted by tt(compinit) is tt(-f )var(dir), which gives -the directory in which tt(compinit) resides. If you source tt(compinit) by -its full pathname, and the option tt(FUNCTION_ARGZERO) is set, as it is by -default unless tt(zsh) is emulating tt(sh) or tt(ksh), this is unnecessary -as tt(compinit) can deduce the directory for itself. It is used in two -ways: to find the program tt(compdump) used by the tt(-d) option, and to -check if the directory should be added to the function search path to find -the completion functions (see below). +to do this is by adding the option tt(-d) whenever tt(compinit) is run. +In this case the dumped file is tt(.zcompdump) in the same directory as the +startup files (i.e. tt($ZDOTDIR) or tt($HOME)); alternatively, an explicit +file name can be given following the tt(-d). On the next call to +tt(compinit -d), the dumped file will be read instead. + +If the parameter tt(_compdir) is set, tt(compinit) uses it has a directory +where completion functions can be found; this is only necessary if they are +not already in the function search path. If the number of completion files changes, tt(compinit) will recognise this and produce a new dump file. However, if the name of a function or the @@ -110,27 +111,30 @@ arguments in the first line of a tt(#compdef) function (as described below) change, it is easiest to delete the dump file by hand so that the next time tt(compinit) will re-create it. -The dumping is actually done by another script, tt(compdump), but you will -only need to source this yourself if you change the configuration +The dumping is actually done by another function, tt(compdump), but you +will only need to run this yourself if you change the configuration (e.g. using tt(compdef)) and then want to dump the new one. The name of -the old dumped file will be remembered for this. +the old dumped file will be remembered for this purpose. subsect(Autoloaded files) The convention for autoloaded functions used in completion is that they start with an underscore; as already mentioned, the tt(fpath/FPATH) -parameter must contain the directory in which they are stored. If -tt(compinit) does not find enough files beginning with an underscore (fewer -than twenty) in the search path, it will try to find more by adding its own -directory to the search path. If you keep all the completion files in this -directory, this means you never have to alter tt(fpath/FPATH) yourself. +parameter must contain the directory in which they are stored. If tt(zsh) +was properly installed on your system, then tt(fpath/FPATH) automatically +contains the required directories. + +For incomplete installations, if tt(compinit) does not find enough files +beginning with an underscore (fewer than twenty) in the search path, it +will try to find more by adding the directory tt(_compdir) to the search +path; if you have run tt(compinstall), this will be set automatically. Furthermore, if the directory in question ends in the path segment tt(Core), or has a subdirectory named tt(Core), tt(compinit) will add all subdirectories of the directory where tt(Core) is to the path: this allows the functions to be in the same format as in the tt(zsh) source distribution. -When tt(compinit) is sourced, it searches all such files accessible via +When tt(compinit) is run, it searches all such files accessible via tt(fpath/FPATH) and reads the first line of each of them. This line should contain one of the tags described below. Files whose first line does not start with one of these tags are not considered to be part of the @@ -158,7 +162,11 @@ var(key-sequences). It creates a widget behaving like the builtin widget var(style), which must be one of those that perform completion, namely tt(complete-word), tt(delete-char-or-list), tt(expand-or-complete), tt(expand-or-complete-prefix), tt(list-choices), tt(menu-complete), -tt(menu-expand-or-complete), or tt(reverse-menu-complete). +tt(menu-expand-or-complete), or tt(reverse-menu-complete). If the +tt(complist) module is loaded (see +ifzman(zmanref(zshmodules))\ +ifnzman(noderef(The complist Module))\ +), the tt(menu-select) widget can be used, too. The widget is then bound to all the var(key-sequences) given, if any: when one of the var(key-sequences) is typed, the function in the file will @@ -238,10 +246,10 @@ function, usable to be put in a setup script. ) enditem() -texinode(Control Functions)(Completion Functions)(Initialisation)(Completion System) +texinode(Control Functions)(Completion Functions)(Initialization)(Completion System) sect(Control Functions) -The initialisation script tt(compinit) re-binds all the keys which perform +The initialization script tt(compinit) re-binds all the keys which perform completion to newly created widgets that all call the supplied widget function tt(_main_complete). This function acts as a wrapper calling the so-called `completer' functions that generate matches. If @@ -382,7 +390,7 @@ with a numeric argument of six (as in `tt(ESC-6 TAB)'), up to six errors are accepted. Hence with a value of `tt(0n)', no correcting completion will be attempted unless a numeric argument is given. -If the value contains `tt(n)' or `tt(N)' and a exclamation mark +If the value contains `tt(n)' or `tt(N)' and an exclamation mark (`tt(!)'), tt(_approximate) will var(not) try to generate corrected completions when given a numeric argument, so in this case the number given should be greater than zero. For example, `tt(2n!)' specifies that @@ -467,6 +475,12 @@ configuration key tt(match_original) has a value of `tt(only)', no `tt(*)' will be inserted. If tt(match_original) has any other non-empty string as its value, this completer will first try to generate matches without, then with a `tt(*)' inserted at the cursor position. + +The generated matches will be offered in a menucompletion unless the +tt(match_insert) configuration key is set to a string starting with +`tt(unambig)'. In this case menucompletion will only be started if no +unambiguous string could be generated that is at least as long as the +original string. ) item(tt(_expand))( This completer function does not really do completion, but instead @@ -652,7 +666,7 @@ one can write a pattern completion function that keeps other functions from being tried simply by setting this parameter to any value. ) item(tt(_multi_parts))( -This functions gets two arguments: a separator character and an +This function gets two arguments: a separator character and an array. As usual, the array may be either the name of an array parameter or a literal array in the form `tt(LPAR()foo bar)tt(RPAR())' (i.e. a list of words separated by white @@ -700,10 +714,13 @@ These functions also accept the `tt(-J)', `tt(-V)', `tt(-X)', `tt(-P)', `tt(-S)', `tt(-q)', `tt(-r)', and `tt(-R)' options from the tt(compadd) builtin. -Finally, the tt(_path_files) function supports one configuration key: -tt(path_expand). If this is set to any non-empty string, the partially +Finally, the tt(_path_files) function supports two configuration keys. +If tt(path_expand) is set to any non-empty string, the partially typed path from the line will be expanded as far as possible even if -trailing pathname components can not be completed. +trailing pathname components can not be completed. And if +tt(path_cursor) is set to a non-empty string, the cursor will be left +after the first ambiguous pathname component even when menucompletion +is used. ) item(tt(_parameters))( This should be used to complete parameter names if you need some of the |