about summary refs log tree commit diff
path: root/Completion/Base/Completer/_ignored
blob: 00dfc42f40414de7c52bd7f7dff25722e95db23d (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
#autoload

# Use ignored matches.

[[ _matcher_num -gt 1 || $compstate[ignored] -eq 0 ]] && return 1

local comp
integer ind

if ! zstyle -a ":completion:${curcontext}:" completer comp; then
  comp=( "${(@)_completers[1,_completer_num-1]}" )
  ind=${comp[(I)_ignored(|:*)]}
  (( ind )) && comp=("${(@)comp[ind,-1]}")
fi

local _comp_no_ignore=yes tmp expl \
      _completer _completer_num \
      _matcher _c_matcher _matchers _matcher_num

_completer_num=1

for tmp in "$comp[@]"; do
  if [[ "$tmp" = *:-* ]]; then
    _completer="${${tmp%:*}[2,-1]//_/-}${tmp#*:}"
    tmp="${tmp%:*}"
  elif [[ $tmp = *:* ]]; then
    _completer="${tmp#*:}"
    tmp="${tmp%:*}"
  else
    _completer="${tmp[2,-1]//_/-}"
  fi
  curcontext="${curcontext/:[^:]#:/:${_completer}:}"

  zstyle -a ":completion:${curcontext}:" matcher-list _matchers ||
      _matchers=( '' )

  _matcher_num=1
  _matcher=''
  for _c_matcher in "$_matchers[@]"; do
    if [[ "$_c_matcher" == +* ]]; then
      _matcher="$_matcher $_c_matcher[2,-1]"
    else
      _matcher="$_c_matcher"
    fi
    if [[ "$tmp" != _ignored ]] && "$tmp"; then
      if zstyle -s ":completion:${curcontext}:" single-ignored tmp &&
         [[ $compstate[old_list] != shown &&
            $compstate[nmatches] -eq 1 ]]; then
        case "$tmp" in
        show) compstate[insert]='' compstate[list]='list force' tmp='' ;;
        menu)
          compstate[insert]=menu
          _description original expl original    
          compadd "$expl[@]" -S '' - "$PREFIX$SUFFIX"
          ;;
        esac
      fi

      return 0
    fi

    (( _matcher_num++ ))
  done

  (( _completer_num++ ))
done

return 1