summaryrefslogtreecommitdiffstats
path: root/lib/Reply/Plugin/Autocomplete/Keywords.pm
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-06-27 15:01:13 -0400
committerJesse Luehrs <doy@tozt.net>2013-06-27 15:01:13 -0400
commit600e0172ac0987d32918a9273308a99206402c8e (patch)
tree4a06e68f4cc6e5d317807c5f34be25d6f23d3bd7 /lib/Reply/Plugin/Autocomplete/Keywords.pm
parent69c37d1c359eb08966d1b1dfbbd6f7ba079a847d (diff)
downloadreply-600e0172ac0987d32918a9273308a99206402c8e.tar.gz
reply-600e0172ac0987d32918a9273308a99206402c8e.zip
split out different completion types
Diffstat (limited to 'lib/Reply/Plugin/Autocomplete/Keywords.pm')
-rw-r--r--lib/Reply/Plugin/Autocomplete/Keywords.pm39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/Reply/Plugin/Autocomplete/Keywords.pm b/lib/Reply/Plugin/Autocomplete/Keywords.pm
new file mode 100644
index 0000000..85bfe1e
--- /dev/null
+++ b/lib/Reply/Plugin/Autocomplete/Keywords.pm
@@ -0,0 +1,39 @@
+package Reply::Plugin::Autocomplete::Keywords;
+use strict;
+use warnings;
+# ABSTRACT: tab completion for perl keywords
+
+use base 'Reply::Plugin';
+
+use B::Keywords qw/@Functions @Barewords/;
+
+=head1 SYNOPSIS
+
+ ; .replyrc
+ [ReadLine]
+ [Autocomplete::Keywords]
+
+=head1 DESCRIPTION
+
+This plugin registers a tab key handler to autocomplete keywords in Perl code.
+
+=cut
+
+sub tab_handler {
+ my $self = shift;
+ my ($line) = @_;
+
+ my ($last_word) = $line =~ /(\w+)$/;
+ return unless $last_word;
+
+ my $re = qr/^\Q$last_word/;
+
+ return grep { $_ =~ $re } @Functions, @Barewords;
+}
+
+=for Pod::Coverage
+ tab_handler
+
+=cut
+
+1;