r80567@dhcp117: nothingmuch | 2008-05-14 19:51:22 +0900
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / CompletionDriver / Keywords.pm
CommitLineData
1989c3d2 1package Devel::REPL::Plugin::CompletionDriver::Keywords;
2use Devel::REPL::Plugin;
3use B::Keywords qw/@Functions @Barewords/;
4use namespace::clean -except => [ 'meta' ];
5
6around complete => sub {
7 my $orig = shift;
8 my ($self, $text, $document) = @_;
9
10 # recursively find the last element
11 my $last = $document;
12 while ($last->can('last_element') && defined($last->last_element)) {
13 $last = $last->last_element;
14 }
15
16 return $orig->(@_)
17 unless $last->isa('PPI::Token::Word');
18
19 my $re = qr/^\Q$last/;
20
21 return $orig->(@_),
22 grep { $_ =~ $re } @Functions, @Barewords;
23};
24
251;
26