From: Sartak Date: Sat, 31 May 2008 16:57:05 +0000 (+0000) Subject: r61346@onn: sartak | 2008-05-31 12:56:47 -0400 X-Git-Tag: v1.003015~88 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDevel-REPL.git;a=commitdiff_plain;h=839614c75c856e2d386fd0c5a0e832142fab5387 r61346@onn: sartak | 2008-05-31 12:56:47 -0400 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 --- diff --git a/lib/Devel/REPL/Plugin/Completion.pm b/lib/Devel/REPL/Plugin/Completion.pm index b4bbb88..05fca4f 100644 --- a/lib/Devel/REPL/Plugin/Completion.pm +++ b/lib/Devel/REPL/Plugin/Completion.pm @@ -24,23 +24,21 @@ has no_term_class_warning => ( 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) = @_;