about summary refs log tree commit diff
path: root/Completion/User/_perl_builtin_funcs
blob: 7ac69828d530ff8084c2c8a067153c7e42d4b84f (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
#autoload
#
# _perl_builtin_funcs - zsh completion function
#
# Adam Spiers <adam@spiers.net>
#
# Calculate all built-in Perl functions.  The result is cached
# for future use.
#

if [[ ${+_perl_builtin_funcs} -eq 0 ]]; then
  typeset -agU _perl_builtin_funcs
  local perlfunc

  if [[ -n "${perlfunc:=$(man -w perlfunc 2>/dev/null; print -l ${^manpath}/man1/perlfunc.1(N) {/usr/man,/usr/local/man}/man1/perlfunc.1(N))}" ]]; then
    _perl_builtin_funcs=( `perl -lne '
                             $in_funcs++, next if /Alphabetical/;     \
                             next unless $in_funcs;                   \
                             if (/^\.Ip "(\w+)/) {                    \
                               print $1 unless $func{$1}; $func{$1}++ \
                             }' $=perlfunc`
               )
  else
    echo "Couldn't find perlfunc man page; giving up."
    return 1
  fi
fi

local expl

_wanted functions expl 'Perl built-in functions' &&
    compadd "$expl[@]" - $_perl_builtin_funcs