about summary refs log tree commit diff
path: root/Completion/Core/_description
blob: c6a7b88075c29d8681cc1d047a31abe576406972 (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
#autoload

local name gropt format gname hidden hide match

gropt=(-J)
hide=()
match=()

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

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

_setup "$1"

name="$2"

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

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

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

if [[ -n "$gname" ]]; then
  if [[ -n "$format" ]]; then
    eval "${name}=($hide $match $gropt ${(q)gname} -X \"${format}\")"
  else
    eval "${name}=($hide $match $gropt ${(q)gname})"
  fi
else
  if [[ -n "$format" ]]; then
    eval "${name}=($hide $match $gropt -default- -X \"${format}\")"
  else
    eval "${name}=($hide $match $gropt -default-)"
  fi
fi

return 0