Avoid using BEFORE_PLUGIN and AFTER_PLUGIN in Completion. it does not play well with role-role composition
git-svn-id: http://dev.catalyst.perl.org/repos/bast/trunk/Devel-REPL@4447
bd8105ee-0ff8-0310-8827-fb3f25b6796d
default => 0,
);
-sub BEFORE_PLUGIN {
+before 'read' => sub {
my ($self) = @_;
+ unless ($self->term->isa("Term::ReadLine::Gnu") and !$self->no_term_class_warning) {
+ warn "Term::ReadLine::Gnu is required for the Completion plugin to work";
+ $self->no_term_class_warning(1);
+ }
+
my $weakself = $self;
weaken($weakself);
$self->term->Attribs->{attempted_completion_function} = sub {
$weakself->_completion(@_);
};
-}
-
-sub AFTER_PLUGIN {
- my ($self) = @_;
-
- warn "Term::ReadLine::Gnu is required for the Completion plugin to work"
- unless $self->term->isa("Term::ReadLine::Gnu") and !$self->no_term_class_warning;
-}
+};
sub _completion {
my ($self, $text, $line, $start, $end) = @_;