summaryrefslogtreecommitdiffstats
path: root/lib/Reply/Plugin/Autocomplete/Lexicals.pm
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-07-04 13:07:16 -0400
committerJesse Luehrs <doy@tozt.net>2013-07-04 13:07:16 -0400
commit903b05bdb8c1224deabd9674bb4be1bae5195312 (patch)
treea9a8d7bf1e8cf44de16981d62bf7b61da1b35c3c /lib/Reply/Plugin/Autocomplete/Lexicals.pm
parentff42543cec4d93057cdff1ae3a635268d00c0296 (diff)
downloadreply-903b05bdb8c1224deabd9674bb4be1bae5195312.tar.gz
reply-903b05bdb8c1224deabd9674bb4be1bae5195312.zip
refactor this to avoid some duplication
Diffstat (limited to 'lib/Reply/Plugin/Autocomplete/Lexicals.pm')
-rw-r--r--lib/Reply/Plugin/Autocomplete/Lexicals.pm10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Reply/Plugin/Autocomplete/Lexicals.pm b/lib/Reply/Plugin/Autocomplete/Lexicals.pm
index 08d4c02..dd953bf 100644
--- a/lib/Reply/Plugin/Autocomplete/Lexicals.pm
+++ b/lib/Reply/Plugin/Autocomplete/Lexicals.pm
@@ -5,6 +5,8 @@ use warnings;
use base 'Reply::Plugin';
+use Reply::Util qw($varname_rx);
+
=head1 SYNOPSIS
; .replyrc
@@ -18,9 +20,6 @@ Perl code.
=cut
-# XXX unicode?
-my $var_name_rx = qr/[\$\@\%]\s*(?:[A-Z_a-z][0-9A-Z_a-z]*)?/;
-
sub new {
my $class = shift;
@@ -41,11 +40,14 @@ sub tab_handler {
my $self = shift;
my ($line) = @_;
- my ($var) = $line =~ /($var_name_rx)$/;
+ my ($var) = $line =~ /($varname_rx)$/;
return unless $var;
my ($sigil, $name_prefix) = $var =~ /(.)(.*)/;
+ # these can't be lexicals
+ return if $sigil eq '&' || $sigil eq '*';
+
my $env = { map { %$_ } values %{ $self->{env} } };
my @env = keys %$env;