zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: zsh and perl
@ 2000-11-15 10:56 Sven Wischnowsky
  2000-11-15 16:03 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Sven Wischnowsky @ 2000-11-15 10:56 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> ...
> 
> Any suggestions for how to avoid the chpwd problem?

I'm sure I'm missing something, but... why not just avoid the cd
altogether? Something like

  new_pms=( $libdir/{[a-Z]*/***/,}*.pm~*blib* )
  new_pms=( "${(@)new_pms#$libdir/}" )

probably testing if $libdir is non-empty before that...

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 5+ messages in thread
* PATCH: zsh and perl
@ 2000-11-14 12:47 Paul Johnson
  2000-11-14 16:10 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Johnson @ 2000-11-14 12:47 UTC (permalink / raw)
  To: zsh-workers; +Cc: adam

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2000-11-16 12:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-11-15 10:56 PATCH: zsh and perl Sven Wischnowsky
2000-11-15 16:03 ` Bart Schaefer
2000-11-16 12:18   ` Adam Spiers
  -- strict thread matches above, loose matches on Subject: below --
2000-11-14 12:47 Paul Johnson
2000-11-14 16:10 ` Bart Schaefer

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).