diff options
Diffstat (limited to 'Completion/Base')
-rw-r--r-- | Completion/Base/Utility/_arguments | 45 | ||||
-rw-r--r-- | Completion/Base/Widget/_complete_help | 9 |
2 files changed, 29 insertions, 25 deletions
diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments index 1f35e8d43..87fb20e6b 100644 --- a/Completion/Base/Utility/_arguments +++ b/Completion/Base/Utility/_arguments @@ -8,15 +8,33 @@ local oldcontext="$curcontext" hasopts rawret optarg singopt alwopt local setnormarg start rest local -a match mbegin mend +subopts=() +singopt=() +while [[ "$1" = -([AMO]*|[CRSWnsw]) ]]; do + case "$1" in + -C) usecc=yes; shift ;; + -O) subopts=( "${(@P)2}" ); shift 2 ;; + -O*) subopts=( "${(@P)${1[3,-1]}}" ); shift ;; + -R) rawret=yes; shift;; + -n) setnormarg=yes; NORMARG=-1; shift;; + -w) optarg=yes; shift;; + -W) alwopt=arg; shift;; + -[Ss]) singopt+=( $1 ); shift;; + -[AM]) singopt+=( $1 $2 ); shift 2 ;; + -[AM]*) singopt+=( $1 ); shift ;; + esac +done + +[[ $1 = ':' ]] && shift +singopt+=( ':' ) # always end with ':' to indicate the end of options + +[[ "$PREFIX" = [-+] ]] && alwopt=arg + long=$argv[(I)--] if (( long )); then local name tmp tmpargv - if [[ long -eq 1 ]]; then - tmpargv=() - else - tmpargv=( "${(@)argv[1,long-1]}" ) - fi + tmpargv=( "${(@)argv[1,long-1]}" ) # optspec's before --, if any name=${~words[1]} [[ "$name" = [^/]*/* ]] && name="$PWD/$name" @@ -290,23 +308,6 @@ if (( long )); then set -- "$tmpargv[@]" "${(@P)name}" fi -subopts=() -singopt=() -while [[ "$1" = -(O*|[CRWnsw]) ]]; do - case "$1" in - -C) usecc=yes; shift ;; - -O) subopts=( "${(@P)2}" ); shift 2 ;; - -O*) subopts=( "${(@P)${1[3,-1]}}" ); shift ;; - -R) rawret=yes; shift;; - -n) setnormarg=yes; NORMARG=-1; shift;; - -w) optarg=yes; shift;; - -s) singopt=(-s); shift;; - -W) alwopt=arg; shift;; - esac -done - -[[ "$PREFIX" = [-+] ]] && alwopt=arg - zstyle -s ":completion:${curcontext}:options" auto-description autod if (( $# )) && comparguments -i "$autod" "$singopt[@]" "$@"; then diff --git a/Completion/Base/Widget/_complete_help b/Completion/Base/Widget/_complete_help index 0563c618f..09637ecb9 100644 --- a/Completion/Base/Widget/_complete_help +++ b/Completion/Base/Widget/_complete_help @@ -6,12 +6,15 @@ _complete_help() { local _sort_tags=_help_sort_tags text i j k tmp typeset -A help_funcs help_tags help_sfuncs help_styles + local -H _help_scan_funcstack="main_complete|complete|approximate|normal" + local -H _help_filter_funcstack="alternative|call_function|describe|dispatch|wanted|requested|all_labels|next_label" + { compadd() { return 1 } zstyle() { - local _f="${${(@)${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(dispatch|wanted|requested|all_labels|next_label)}% *}" + local _f="${${(@)${(@)funcstack[2,(i)_($~_help_scan_funcstack)]}:#(_($~_help_filter_funcstack)|\((eval|anon)\))}% *}" - [[ -z "$_f" ]] && _f="${${(@)funcstack[2,(i)_(main_complete|complete|approximate|normal)]}:#_(dispatch|wanted|requested|all_labels|next_label)}" + [[ -z "$_f" ]] && _f="${${(@)funcstack[2,(i)_($~_help_scan_funcstack)]}:#(_($~_help_filter_funcstack)|\((eval|anon)\))}" if [[ "$help_sfuncs[$2]" != *${_f}* || "$help_styles[${2}${_f}]" != *${3}* ]]; then @@ -73,7 +76,7 @@ _complete_help() { } _help_sort_tags() { - local f="${${(@)${(@)funcstack[3,(i)_(main_complete|complete|approximate|normal)]}:#(_(dispatch|wanted|requested|all_labels|next_label)|\(eval\))}% *}" + local f="${${(@)${(@)funcstack[3,(i)_($~_help_scan_funcstack)]}:#(_($~_help_filter_funcstack)|\((eval|anon)\))}% *}" if [[ "$help_funcs[$curcontext]" != *${f}* || "$help_tags[${curcontext}${f}]" != *(${(j:|:)~argv})* ]]; then |