summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-07-10 02:13:25 -0400
committerJesse Luehrs <doy@tozt.net>2013-07-10 02:13:25 -0400
commit99202371c7784d346cf43a4c25c64bb6d7630f10 (patch)
treed2a55982c2ff990ec6251a43ed421feb23818da8
parent3db6d5dccb0b1fade69467e1800a8eb763bd3158 (diff)
downloadreply-99202371c7784d346cf43a4c25c64bb6d7630f10.tar.gz
reply-99202371c7784d346cf43a4c25c64bb6d7630f10.zip
invert the sense of the package message too
-rw-r--r--lib/Reply/Plugin/Autocomplete/Functions.pm12
-rw-r--r--lib/Reply/Plugin/Defaults.pm12
-rw-r--r--lib/Reply/Plugin/Packages.pm8
3 files changed, 12 insertions, 20 deletions
diff --git a/lib/Reply/Plugin/Autocomplete/Functions.pm b/lib/Reply/Plugin/Autocomplete/Functions.pm
index 233ec4d..257cacf 100644
--- a/lib/Reply/Plugin/Autocomplete/Functions.pm
+++ b/lib/Reply/Plugin/Autocomplete/Functions.pm
@@ -28,6 +28,8 @@ sub tab_handler {
my ($before, $fragment) = $line =~ /(.*?)(${module_name_rx}(::)?)$/;
return unless $fragment;
+ my $current_package = ($self->publish('package'))[-1];
+
my ($package, $func);
if ($fragment =~ /:/) {
($package, $func) = ($fragment =~ /^(.+:)(\w*)$/);
@@ -35,20 +37,14 @@ sub tab_handler {
$package =~ s/:{1,2}$//;
}
else {
- $package = $self->{'package'};
+ $package = $current_package;
$func = $fragment;
}
return
- map { $package eq $self->{'package'} ? $_ : "$package\::$_" }
+ map { $package eq $current_package ? $_ : "$package\::$_" }
grep { $func ? /^\Q$func/ : 1 }
'Package::Stash'->new($package)->list_all_symbols('CODE');
}
-sub package {
- my $self = shift;
- my ($pkg) = @_;
- $self->{'package'} = $pkg;
-}
-
1;
diff --git a/lib/Reply/Plugin/Defaults.pm b/lib/Reply/Plugin/Defaults.pm
index 89c618e..9e346d0 100644
--- a/lib/Reply/Plugin/Defaults.pm
+++ b/lib/Reply/Plugin/Defaults.pm
@@ -21,7 +21,6 @@ sub new {
my $self = $class->SUPER::new(@_);
$self->{quit} = 0;
- $self->{package} = 'main';
return $self;
}
@@ -48,9 +47,10 @@ sub compile {
my $self = shift;
my ($next, $line, %args) = @_;
- my $env = { map { %$_ } $self->publish('lexical_environment') };
+ my $env = { map { %$_ } $self->publish('lexical_environment') };
+ my $package = ($self->publish('package'))[-1];
- my $prefix = "package $self->{package};\n$PREFIX";
+ my $prefix = "package $package;\n$PREFIX";
my $code = eval_closure(
source => "sub {\n$prefix;\n$line\n}",
@@ -66,12 +66,6 @@ sub compile {
return $code;
}
-sub package {
- my $self = shift;
- my ($package) = @_;
- $self->{package} = $package;
-}
-
sub execute {
my $self = shift;
my ($next, $code, @args) = @_;
diff --git a/lib/Reply/Plugin/Packages.pm b/lib/Reply/Plugin/Packages.pm
index a206d6e..75b459e 100644
--- a/lib/Reply/Plugin/Packages.pm
+++ b/lib/Reply/Plugin/Packages.pm
@@ -27,8 +27,6 @@ sub new {
my $self = $class->SUPER::new(@_);
$self->{package} = $opts{default_package} || 'main';
- $self->publish('package', $self->{package});
-
return $self;
}
@@ -56,9 +54,13 @@ sub compile {
# eval_closure's environment parameter since we need to access the
# information in a BEGIN block
$self->{package} = our $package;
- $self->publish('package', $self->{package});
return @result;
}
+sub package {
+ my $self = shift;
+ return $self->{package};
+}
+
1;