about summary refs log tree commit diff
path: root/Completion/Core/_description
blob: 2c4232ade57ced97d55f68352a74a4c237c5dd02 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#autoload

local name gropt=-J format gname hidden hide match opts

opts=()

if [[ "$1" = -([12]|)[VJ] ]]; then
  gropt="$1"
  shift
fi

_lastdescr=( "$_lastdescr[@]" "$3" )

zstyle -s ":completion:${curcontext}:$1" group-name gname &&
    [[ -z "$gname" ]] && gname="$1"

_setup "$1" "${gname:--default-}"

name="$2"

zstyle -s ":completion:${curcontext}:$1" format format ||
    zstyle -s ":completion:${curcontext}:descriptions" format format

if zstyle -s ":completion:${curcontext}:$1" hidden hidden &&
   [[ "$hidden" = (all|yes|true|1|on) ]]; then
  [[ "$hidden" = all ]] && format=''
  opts=(-n)
fi
zstyle -s ":completion:${curcontext}:$1" matcher match &&
    opts=($opts -M "$match")
[[ -n "$_matcher" ]] && opts=($opts -M "$_matcher")

if [[ -z "$_comp_no_ignore" ]]; then
  zstyle -a ":completion:${curcontext}:$1" ignored-patterns _comp_ignore ||
    _comp_ignore=()

  zstyle -s ":completion:${curcontext}:$1" ignore-line hidden &&
    case "$hidden" in
    true|yes|on|1) _comp_ignore=( "$_comp_ignore[@]" "$words[@]" );;
    current)       _comp_ignore=( "$_comp_ignore[@]" "$words[CURRENT]" );;
    current-shown) [[ "$compstate[old_list]" = *shown* ]] &&
                       _comp_ignore=( "$_comp_ignore[@]" "$words[CURRENT]" );;
    other)         _comp_ignore=( "$_comp_ignore[@]"
                                  "${(@)words[1,CURRENT-1]}"
				  "${(@)words[CURRENT+1,-1]}" );;
    esac

  (( $#_comp_ignore )) && opts=( $opts -F _comp_ignore )
else
  _comp_ignore=()
fi

shift 2
[[ -n "$format" ]] && zformat -f format "$format" "d:$1" "${(@)argv[2,-1]}"

if [[ -n "$gname" ]]; then
  if [[ -n "$format" ]]; then
    set -A "$name" "$opts[@]" "$gropt" "$gname" -X "$format"
  else
    set -A "$name" "$opts[@]" "$gropt" "$gname"
  fi
else
  if [[ -n "$format" ]]; then
    set -A "$name" "$opts[@]" "$gropt" -default- -X "$format"
  else
    set -A "$name" "$opts[@]" "$gropt" -default-
  fi
fi

return 0