From 4a34edc4855ef9d6a74c4658a2ed4f0f8bc1f130 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Sun, 5 Sep 1999 22:04:03 +0000 Subject: Initial revision --- Completion/User/_perl_basepods | 30 +++++++++++++++++++++++ Completion/User/_perl_builtin_funcs | 29 +++++++++++++++++++++++ Completion/User/_perl_modules | 47 +++++++++++++++++++++++++++++++++++++ Completion/User/_perldoc | 23 ++++++++++++++++++ 4 files changed, 129 insertions(+) create mode 100644 Completion/User/_perl_basepods create mode 100644 Completion/User/_perl_builtin_funcs create mode 100644 Completion/User/_perl_modules create mode 100644 Completion/User/_perldoc (limited to 'Completion/User') diff --git a/Completion/User/_perl_basepods b/Completion/User/_perl_basepods new file mode 100644 index 000000000..f4e70382b --- /dev/null +++ b/Completion/User/_perl_basepods @@ -0,0 +1,30 @@ +#autoload +# +# _perl_basepods - zsh completion function +# +# Adam Spiers +# +# Calculate all installed Perl base pods (perlfunc, perlfaq etc.). +# The result is cached for future use. +# + +if [[ ${+_perl_basepods} -eq 0 ]]; then + typeset -agU _perl_basepods + + if which basdepods >/dev/null; then + _perl_basepods=( ${$(basepods):t:r} ) + else + local podpath + podpath=$(perl -MConfig -e 'print "$Config{installprivlib}/pod"') + if [[ ! -e $podpath/perl.pod ]]; then + echo "Couldn't find perl.pod from Config.pm; giving up." + return 1 + else + cd $podpath + _perl_basepods=( *.pod(:r:t) ) + cd $OLDPWD + fi + fi +fi + +compadd - $_perl_basepods diff --git a/Completion/User/_perl_builtin_funcs b/Completion/User/_perl_builtin_funcs new file mode 100644 index 000000000..a8facda08 --- /dev/null +++ b/Completion/User/_perl_builtin_funcs @@ -0,0 +1,29 @@ +#autoload +# +# _perl_builtin_funcs - zsh completion function +# +# Adam Spiers +# +# 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 perlfunc=`man -w perlfunc 2>&1`; 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 + +compadd - $_perl_builtin_funcs diff --git a/Completion/User/_perl_modules b/Completion/User/_perl_modules new file mode 100644 index 000000000..c909055ba --- /dev/null +++ b/Completion/User/_perl_modules @@ -0,0 +1,47 @@ +#compdef pmpath pmvers pmdesc pmload pmexp pmeth pmls pmcat pman pmfunc podgrep podtoc podpath +# +# +# _perl_modules - zsh completion function +# +# Adam Spiers +# +# Calculate all installed Perl modules. The result is cached +# for future use. +# +# Bugs: +# - can't cope with multiple installs of Perl + +# Change this if you have pminst and want to use it. The zsh code +# actually produces better results because pminst misses modules of +# the form Foo/bar/Baz.pm through its clumsy -d && /^[A-Z]/ && prune +# algorithm (the zsh code does almost the same, but only misses modules +# which don't begin with an uppercase letter). +local try_to_use_pminst=0 + +if [[ ${+_perl_modules} -eq 0 ]]; then + if [[ $try_to_use_pminst -ne 0 ]] && which pminst >/dev/null; then + _perl_modules=( $(pminst) ) + else + local inc libdir new_pms + inc=( $( perl -e 'print "@INC"' ) ) + typeset -agU _perl_modules # _perl_modules is global, no duplicates + _perl_modules=( ) + + for libdir in $inc; do + # Ignore cwd - could be too expensive e.g. if we're near / + if [[ $libdir == '.' ]]; then break; fi + + # Find all modules + cd $libdir + new_pms=( {[A-Z]*/**/,}*.pm(N) ) + cd $OLDPWD + + # Convert to Perl nomenclature + new_pms=( ${new_pms:r:fs#/#::#} ) + + _perl_modules=( $new_pms $_perl_modules ) + done + fi +fi + +compadd - $_perl_modules diff --git a/Completion/User/_perldoc b/Completion/User/_perldoc new file mode 100644 index 000000000..cd5383a45 --- /dev/null +++ b/Completion/User/_perldoc @@ -0,0 +1,23 @@ +#compdef perldoc +# +# +# _perldoc - zsh completion function for perldoc +# +# Adam Spiers +# +# Behaviour should be roughly equivalent to: +# compctl -k perl_modules -k perl_basepods -f +# -x 'c[-1,-f]' -k perl_funcs -- +# + -k man_pages +# perldoc + +if [[ $CURRENT -eq 3 && $words[2] == '-f' ]]; then + _perl_builtin_funcs +elif [[ $CURRENT -eq 3 && $words[2] == '-q' ]]; then + zle -R "I can't read your mind!" +else + _perl_modules + _perl_basepods + _path_files -/ -g '*.(pod|pm)' +fi + -- cgit 1.4.1