summary refs log tree commit diff
path: root/Completion/User/_perl_modules
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-09-05 22:04:03 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-09-05 22:04:03 +0000
commit4a34edc4855ef9d6a74c4658a2ed4f0f8bc1f130 (patch)
tree7fc49640b47e2caecb10c4a8d3867d5df51362be /Completion/User/_perl_modules
parent63680c108bd05f3cb9401a7fcf547b53381d2c17 (diff)
downloadzsh-4a34edc4855ef9d6a74c4658a2ed4f0f8bc1f130.tar.gz
zsh-4a34edc4855ef9d6a74c4658a2ed4f0f8bc1f130.tar.xz
zsh-4a34edc4855ef9d6a74c4658a2ed4f0f8bc1f130.zip
Initial revision
Diffstat (limited to 'Completion/User/_perl_modules')
-rw-r--r--Completion/User/_perl_modules47
1 files changed, 47 insertions, 0 deletions
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 <adam@spiers.net>
+#
+# 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