From 99202371c7784d346cf43a4c25c64bb6d7630f10 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 10 Jul 2013 02:13:25 -0400 Subject: invert the sense of the package message too --- lib/Reply/Plugin/Autocomplete/Functions.pm | 12 ++++-------- lib/Reply/Plugin/Defaults.pm | 12 +++--------- lib/Reply/Plugin/Packages.pm | 8 +++++--- 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; -- cgit v1.2.3-54-g00ecf