X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDevel-REPL.git;a=blobdiff_plain;f=lib%2FDevel%2FREPL%2FPlugin%2FCompletionDriver%2FKeywords.pm;h=d953ee89268df5490fb69464ad1c9a945111fd17;hp=55d5240f6ba91f4af6857ae603065e05deb9cbc5;hb=9d2a4940f5958d82828272364ef754e9290b6113;hpb=8051a5e0e588f2c30779c2e2982f33e6fb27fda9 diff --git a/lib/Devel/REPL/Plugin/CompletionDriver/Keywords.pm b/lib/Devel/REPL/Plugin/CompletionDriver/Keywords.pm index 55d5240..d953ee8 100644 --- a/lib/Devel/REPL/Plugin/CompletionDriver/Keywords.pm +++ b/lib/Devel/REPL/Plugin/CompletionDriver/Keywords.pm @@ -1,7 +1,19 @@ +use strict; +use warnings; package Devel::REPL::Plugin::CompletionDriver::Keywords; +# ABSTRACT: Complete Perl keywords and operators + +our $VERSION = '1.003027'; + use Devel::REPL::Plugin; +use Devel::REPL::Plugin::Completion; # die early if cannot load use B::Keywords qw/@Functions @Barewords/; -use namespace::clean -except => [ 'meta' ]; +use namespace::autoclean; + +sub BEFORE_PLUGIN { + my $self = shift; + $self->load_plugin('Completion'); +} around complete => sub { my $orig = shift; @@ -12,6 +24,12 @@ around complete => sub { return $orig->(@_) unless $last->isa('PPI::Token::Word'); + # don't complete keywords on foo->method + return $orig->(@_) + if $last->sprevious_sibling + && $last->sprevious_sibling->isa('PPI::Token::Operator') + && $last->sprevious_sibling->content eq '->'; + my $re = qr/^\Q$last/; return $orig->(@_), @@ -20,3 +38,12 @@ around complete => sub { 1; +__END__ + +=pod + +=head1 AUTHOR + +Shawn M Moore, C<< >> + +=cut