mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 22:11:54 +02:00
Changes inspired by Paul J. in case multiple versions of perl are installed.
This commit is contained in:
parent
2d77bd0d58
commit
ea807260e4
2 changed files with 49 additions and 23 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2000-11-14 Bart Schaefer <schaefer@zsh.org>
|
||||
|
||||
* 13165 plus unposted: Completion/User/_perl_modules: `builtin cd'
|
||||
is better than chdir; make sure the variable name used for the cache
|
||||
has a leading underscore, but strip that off to get the name under
|
||||
which the cache is stored and retrieved; cache separately for each
|
||||
command basename (e.g., perl5.00405 v. perl5.00503), not just each
|
||||
full path name.
|
||||
|
||||
* Paul Johnson: 13164: Completion/User/_perl_modules: If a full
|
||||
path was given for the command after which perl modules are being
|
||||
completed, look up and cache the modules under the full name; use
|
||||
chdir instead of cd in case of a function wrapper for cd.
|
||||
|
||||
2000-11-14 Sven Wischnowsky <wischnow@zsh.org>
|
||||
|
||||
* 13163: Src/Modules/zpty.c: don't be sure that read-ahead doesn't
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
_perl_modules () {
|
||||
local opts
|
||||
zparseopts -D -a opts S: q
|
||||
|
||||
|
||||
# Set a sensible default caching policy. This has to be done inside
|
||||
# this function otherwise we wouldn't know the context for the style.
|
||||
local update_policy
|
||||
|
@ -29,54 +29,66 @@ _perl_modules () {
|
|||
zstyle ":completion:${curcontext}:" cache-policy \
|
||||
_perl_modules_caching_policy
|
||||
fi
|
||||
|
||||
if ( [[ ${+_perl_modules} -eq 0 ]] || _cache_invalid perl_modules ) &&
|
||||
! _retrieve_cache perl_modules;
|
||||
|
||||
local perl=${words[0]%doc} perl_modules
|
||||
if whence $perl >/dev/null; then
|
||||
perl_modules=_${${perl//[^[:alnum:]]/_}#_}_modules
|
||||
elif (( ${+commands[perl]} )); then
|
||||
perl=perl
|
||||
perl_modules=_perl_modules
|
||||
else
|
||||
perl=
|
||||
perl_modules=_unknown_perl_modules
|
||||
fi
|
||||
|
||||
if ( [[ ${(P)+perl_modules} -eq 0 ]] || _cache_invalid $perl_modules ) &&
|
||||
! _retrieve_cache ${perl_modules#_};
|
||||
then
|
||||
if zstyle -t ":completion:${curcontext}:modules" try-to-use-pminst &&
|
||||
(( ${+commands[pminst]} ));
|
||||
then
|
||||
_perl_modules=( $(pminst) )
|
||||
set -A $perl_modules $(pminst)
|
||||
else
|
||||
local inc libdir new_pms
|
||||
if (( ${+commands[perl]} )); then
|
||||
inc=( $( perl -e 'print "@INC"' ) )
|
||||
|
||||
if [[ ${+perl} -eq 1 ]]; then
|
||||
inc=( $( $perl -e 'print "@INC"' ) )
|
||||
else
|
||||
# If perl isn't there, one wonders why the user's trying to
|
||||
# complete Perl modules. Maybe her $path is wrong?
|
||||
_message "Didn't find perl on \$PATH; guessing @INC ..."
|
||||
|
||||
|
||||
inc=( /usr/lib/perl5{,/{site_perl/,}<5->.([0-9]##)}(N)
|
||||
${(s.:.)PERL5LIB} )
|
||||
fi
|
||||
|
||||
typeset -agU _perl_modules # _perl_modules is global, no duplicates
|
||||
_perl_modules=( )
|
||||
|
||||
|
||||
typeset -agU $perl_modules # $perl_modules is global, no duplicates
|
||||
set -A $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
|
||||
if [[ -d $libdir && -x $libdir ]]; then
|
||||
cd $libdir
|
||||
builtin cd $libdir
|
||||
new_pms=( {[A-Z]*/***/,}*.pm~*blib* )
|
||||
cd $OLDPWD
|
||||
builtin cd $OLDPWD
|
||||
fi
|
||||
|
||||
|
||||
# Convert to Perl nomenclature
|
||||
new_pms=( ${new_pms:r:fs#/#::#} )
|
||||
|
||||
_perl_modules=( $new_pms $_perl_modules )
|
||||
|
||||
set -A $perl_modules $new_pms ${(P)perl_modules}
|
||||
done
|
||||
fi
|
||||
|
||||
_store_cache perl_modules _perl_modules
|
||||
|
||||
_store_cache ${perl_modules#_} $perl_modules
|
||||
fi
|
||||
|
||||
|
||||
local expl
|
||||
|
||||
_wanted modules expl 'Perl modules' compadd "$opts[@]" -a _perl_modules
|
||||
|
||||
_wanted modules expl 'Perl modules' compadd "$opts[@]" -a $perl_modules
|
||||
}
|
||||
|
||||
_perl_modules_caching_policy () {
|
||||
|
|
Loading…
Reference in a new issue