Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: zsh and perl
- X-seq: zsh-workers 13164
- From: Paul Johnson <paulj@xxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: zsh and perl
- Date: Tue, 14 Nov 2000 13:47:03 +0100
- Cc: adam@xxxxxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
I use both zsh and perl heavily and there were a couple of things about
the perldoc completion that were annoying me.
1. cd was used which called my cd function
2. with multiple versions of perl around it's nice to complete modules
specific to the version of perldoc being used
The following patch addresses these two issues. I'd be grateful if you
would have a good look at it since my shell coding skills are not much
to shout about, and comment on it or include it if you feel it's
appropriate.
--- _perl_modules.org Wed Oct 18 15:50:25 2000
+++ _perl_modules Tue Nov 14 13:20:10 2000
@@ -29,18 +29,30 @@
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 [[ -f $perl && -x $perl ]]; then
+ perl_modules=${perl//\\//_}_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?
@@ -50,8 +62,8 @@
${(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 /
@@ -59,24 +71,24 @@
# Find all modules
if [[ -d $libdir && -x $libdir ]]; then
- cd $libdir
+ chdir $libdir
new_pms=( {[A-Z]*/***/,}*.pm~*blib* )
- cd $OLDPWD
+ chdir $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 ${(P)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 () {
--
Paul Johnson - paulj@xxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author