From: Paul Johnson <paulj@olsen.ch>
To: zsh-workers@sunsite.auc.dk
Cc: adam@spiers.net
Subject: PATCH: zsh and perl
Date: Tue, 14 Nov 2000 13:47:03 +0100 [thread overview]
Message-ID: <20001114134703.D6034@sen.olsen.ch> (raw)
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@olsen.ch
next reply other threads:[~2000-11-14 12:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-11-14 12:47 Paul Johnson [this message]
2000-11-14 16:10 ` Bart Schaefer
2000-11-15 10:56 Sven Wischnowsky
2000-11-15 16:03 ` Bart Schaefer
2000-11-16 12:18 ` Adam Spiers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20001114134703.D6034@sen.olsen.ch \
--to=paulj@olsen.ch \
--cc=adam@spiers.net \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).