diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | Completion/Zsh/Type/_command_names | 8 | ||||
-rw-r--r-- | Completion/Zsh/Type/_functions | 8 | ||||
-rw-r--r-- | Completion/Zsh/Type/_parameters | 8 | ||||
-rw-r--r-- | Doc/Zsh/compsys.yo | 28 |
5 files changed, 49 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog index 5c25e3bc8..fb8fcedb4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-03-08 Barton E. Schaefer <schaefer@zsh.org> + + * Greg Klanderman: 28846: Completion/Zsh/Type/_functions, + Completion/Zsh/Type/_command_names, + Completion/Zsh/Type/_parameters, Doc/Zsh/compsys.yo: adapt + prefix-needed zstyle to handle the completion function naming + convention of a leading underscore. + 2011-03-06 Peter Stephenson <p.w.stephenson@ntlworld.com> * 28866: Src/exec.c, Test/A04redirect.ztst: With POSIX_BUILTINS, @@ -14302,5 +14310,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5216 $ +* $Revision: 1.5217 $ ***************************************************** diff --git a/Completion/Zsh/Type/_command_names b/Completion/Zsh/Type/_command_names index f57d05226..1f2af5700 100644 --- a/Completion/Zsh/Type/_command_names +++ b/Completion/Zsh/Type/_command_names @@ -4,10 +4,14 @@ # complete only external commands and executable files. This and a # `-' as the first argument is then removed from the arguments. -local args defs +local args defs ffilt zstyle -t ":completion:${curcontext}:commands" rehash && rehash +zstyle -t ":completion:${curcontext}:functions" prefix-needed && \ + [[ $PREFIX != [_.]* ]] && \ + ffilt='[(I)[^_.]*]' + defs=( 'commands:external command:_path_commands' ) @@ -24,7 +28,7 @@ else defs=( "$defs[@]" 'builtins:builtin command:compadd -k builtins' - 'functions:shell function:compadd -k functions' + "functions:shell function:compadd -k functions$ffilt" 'aliases:alias:compadd -k aliases' 'suffix-aliases:suffix alias:_suffix_alias_files' 'reserved-words:reserved word:compadd -k reswords' diff --git a/Completion/Zsh/Type/_functions b/Completion/Zsh/Type/_functions index 912a7f134..4d336695d 100644 --- a/Completion/Zsh/Type/_functions +++ b/Completion/Zsh/Type/_functions @@ -1,5 +1,9 @@ #compdef unfunction -local expl +local expl ffilt -_wanted functions expl 'shell function' compadd -k "$@" - functions +zstyle -t ":completion:${curcontext}:functions" prefix-needed && \ + [[ $PREFIX != [_.]* ]] && \ + ffilt='[(I)[^_.]*]' + +_wanted functions expl 'shell function' compadd -k "$@" - "functions$ffilt" diff --git a/Completion/Zsh/Type/_parameters b/Completion/Zsh/Type/_parameters index 097a96760..5156e3e2d 100644 --- a/Completion/Zsh/Type/_parameters +++ b/Completion/Zsh/Type/_parameters @@ -6,7 +6,7 @@ # If you specify a -g option with a pattern, the pattern will be used to # restrict the type of parameters matched. -local expl pattern fakes faked tmp +local expl pattern fakes faked tmp pfilt pattern=(-g \*) zparseopts -D -K -E g:=pattern @@ -23,8 +23,12 @@ if zstyle -a ":completion:${curcontext}:" fake-parameters tmp; then done fi +zstyle -t ":completion:${curcontext}:parameters" prefix-needed && \ + [[ $PREFIX != [_.]* ]] && \ + pfilt='[^_.]' + _wanted parameters expl parameter \ compadd "$@" -Q - \ - "${(@k)parameters[(R)${pattern[2]}~*local*]}" \ + "${(@M)${(@k)parameters[(R)${pattern[2]}~*local*]}:#${~pfilt}*}" \ "$fakes[@]" \ "${(@)${(@M)faked:#${~pattern[2]}}%%:*}" diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 4a24df74e..f878ebcab 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -2298,13 +2298,29 @@ The default value for this style is `false'. ) kindex(prefix-needed, completion style) item(tt(prefix-needed))( -This, too, is used for matches with a common prefix. If it is set to -`true' this common prefix must be typed by the user to generate the -matches. In the case of command options, this means that the initial -`tt(-)', `tt(+)', or `tt(-)tt(-)' must be typed explicitly before option -names will be completed. +This style is also relevant for matches with a common prefix. If it is +set to `true' this common prefix must be typed by the user to generate +the matches. -The default value for this style is `true'. +The style is applicable to the tt(options), tt(signals), tt(jobs), +tt(functions), and tt(parameters) completion tags. + +For command options, this means that the initial `tt(-)', `tt(+)', or +`tt(-)tt(-)' must be typed explicitly before option names will be +completed. + +For signals, an initial `tt(-)' is required before signal names will +be completed. + +For jobs, an initial `tt(%)' is required before job names will be +completed. + +For function and parameter names, an initial `tt(_)' or `tt(.)' is +required before function or parameter names starting with those +characters will be completed. + +The default value for this style is `false' for tt(function) and +tt(parameter) completions, and `true' otherwise. ) kindex(preserve-prefix, completion style) item(tt(preserve-prefix))( |