summaryrefslogtreecommitdiffstats
path: root/lib/Reply/Plugin/Autocomplete/Keywords.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Reply/Plugin/Autocomplete/Keywords.pm')
-rw-r--r--lib/Reply/Plugin/Autocomplete/Keywords.pm27
1 files changed, 13 insertions, 14 deletions
diff --git a/lib/Reply/Plugin/Autocomplete/Keywords.pm b/lib/Reply/Plugin/Autocomplete/Keywords.pm
index ee863d1..a17ec41 100644
--- a/lib/Reply/Plugin/Autocomplete/Keywords.pm
+++ b/lib/Reply/Plugin/Autocomplete/Keywords.pm
@@ -1,9 +1,9 @@
-package Reply::Plugin::Autocomplete::Keywords;
+package main;
use strict;
use warnings;
# ABSTRACT: tab completion for perl keywords
-use base 'Reply::Plugin';
+use mop;
use B::Keywords qw/@Functions @Barewords/;
@@ -19,20 +19,19 @@ This plugin registers a tab key handler to autocomplete keywords in Perl code.
=cut
-sub tab_handler {
- my $self = shift;
- my ($line) = @_;
+class Reply::Plugin::Autocomplete::Keywords extends Reply::Plugin {
+ method tab_handler ($line) {
+ my ($before, $last_word) = $line =~ /(.*?)(\w+)$/;
+ return unless $last_word;
+ return if $before =~ /^#/; # command
+ return if $before =~ /::$/; # Package::function call
+ return if $before =~ /->\s*$/; # method call
+ return if $before =~ /[\$\@\%\&\*]\s*$/;
- my ($before, $last_word) = $line =~ /(.*?)(\w+)$/;
- return unless $last_word;
- return if $before =~ /^#/; # command
- return if $before =~ /::$/; # Package::function call
- return if $before =~ /->\s*$/; # method call
- return if $before =~ /[\$\@\%\&\*]\s*$/;
+ my $re = qr/^\Q$last_word/;
- my $re = qr/^\Q$last_word/;
-
- return grep { $_ =~ $re } @Functions, @Barewords;
+ return grep { $_ =~ $re } @Functions, @Barewords;
+ }
}
1;