whitespace fixes
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / CompletionDriver / INC.pm
index 0166c8c..cdcf74f 100644 (file)
@@ -1,8 +1,15 @@
+use strict;
+use warnings;
 package Devel::REPL::Plugin::CompletionDriver::INC;
 use Devel::REPL::Plugin;
 use File::Next;
 use File::Spec;
-use namespace::clean -except => [ 'meta' ];
+use namespace::autoclean;
+
+sub BEFORE_PLUGIN {
+    my $self = shift;
+    $self->load_plugin('Completion');
+}
 
 around complete => sub {
   my $orig = shift;
@@ -57,6 +64,9 @@ around complete => sub {
 
   my @found;
 
+  # most VCSes don't litter every single fucking directory with garbage. if you
+  # know of any other, just stick them in here. noone wants to complete
+  # Devel::REPL::Plugin::.svn
   my %ignored =
   (
       '.'    => 1,
@@ -64,10 +74,11 @@ around complete => sub {
       '.svn' => 1,
   );
 
+  # this will take a directory and add to @found all of the possible matches
   my $add_recursively;
   $add_recursively = sub {
     my ($path, $iteration, @more) = @_;
-    opendir((my $dirhandle), $path);
+    opendir((my $dirhandle), $path) || return;
     for (grep { !$ignored{$_} } readdir $dirhandle)
     {
       my $match = $_;
@@ -90,9 +101,13 @@ around complete => sub {
     }
   };
 
+  # look through all of
   INC: for (@INC)
   {
     my $path = $_;
+
+    # match all of the fragments they have, so "use Moose::Meta::At<tab>"
+    # will only begin looking in ../Moose/Meta/
     for my $subdir (@directories)
     {
       $path = File::Spec->catdir($path, $subdir);
@@ -107,3 +122,15 @@ around complete => sub {
 
 1;
 
+__END__
+
+=head1 NAME
+
+Devel::REPL::Plugin::CompletionDriver::INC - Complete module names in use and require
+
+=head1 AUTHOR
+
+Shawn M Moore, C<< <sartak at gmail dot com> >>
+
+=cut
+