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

_all_matches() {
  local old

  zstyle -s ":completion:${curcontext}:" old-matches old

  if [[ "$old" = (only|true|yes|1|on) ]]; then

    if [[ -n "$compstate[old_list]" ]]; then
      compstate[insert]=all
      compstate[old_list]=keep
      return 0
    fi

    [[ "$old" = *only* ]] && return 1
  fi

  (( $comppostfuncs[(I)_all_matches_end] )) ||
      comppostfuncs=( "$comppostfuncs[@]" _all_matches_end )

  _all_matches_context=":completion:${curcontext}:"

  return 1
}

_all_matches_end() {
  local not

  zstyle -s "$_all_matches_context" avoid-completer not ||
      not=( _expand _old_list _correct _approximate )

  if [[ "$compstate[nmatches]" -gt 1 && $not[(I)(|_)$_completer] -eq 0 ]]; then
    local expl

    if zstyle -t "$_all_matches_context" insert; then
      compstate[insert]=all
    else
      _description all-matches expl 'all matches'
      compadd "$expl[@]" -C
    fi
  fi

  unset _all_matches_context
}

_all_matches "$@"