Skip Menu |

This queue is for tickets about the Devel-REPL CPAN distribution.

Report information
The Basics
Id: 45879
Status: resolved
Priority: 0/
Queue: Devel-REPL

People
Owner: Nobody in particular
Requestors: CMUNGALL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 1.003007
  • 1.003009
Fixed in: 1.003010



Subject: Can't locate object method "stifle_history"
#!/usr/bin/env perl use Devel::REPL; my $repl = Devel::REPL->new; $repl->load_plugin($_) for qw(ReadLineHistory LexEnv); $repl->run; results in: Can't locate object method "stifle_history" via package "Term::ReadLine::Stub" at /Library/Perl/5.8.8/Devel/REPL/Plugin/ReadLineHistory.pm line 23, <DATA> line 1.
This was another place where the functionality was based on Term::ReadLine::Gnu specific history control. I've attached a modified plugin file that uses the appropriate method depending on whether or not the Term::ReadLine is Perl or Gnu. The attached code appears to load for both Term::ReadLine::Gnu and Term::ReadLine::Perl. I still have not figured out how to get it to load before the run() to test. Regards, Chris
Subject: ReadLineHistory.pm
# First cut at using the readline history directly rather than reimplementing # it. It does save history but it's a little crappy; still playing with it ;) # # epitaph, 22nd April 2007 package Devel::REPL::Plugin::ReadLineHistory; use Devel::REPL::Plugin; use File::HomeDir; use File::Spec; my $hist_file = $ENV{PERLREPL_HISTFILE} || File::Spec->catfile(File::HomeDir->my_home, '.perlreplhist'); # HISTLEN should probably be in a config file to stop people accidentally # truncating their history if they start the program and forget to set # PERLREPL_HISTLEN my $hist_len=$ENV{PERLREPL_HISTLEN} || 100; around 'run' => sub { my $orig=shift; my ($self, @args)=@_; if ($self->term->Attribs->{ReadLine} eq 'Term::ReadLine::Gnu') { $self->term->stifle_history($hist_len); } if ($self->term->Attribs->{ReadLine} eq 'Term::ReadLine::Perl') { $self->term->Attribs->{MaxHistorySize} = $hist_len; } -f($hist_file) && $self->term->ReadHistory($hist_file); $self->term->Attribs->{do_expand}=1; $self->$orig(@args); $self->term->WriteHistory($hist_file) || $self->print("warning: failed to write history file $hist_file"); }; 1; __END__ =head1 NAME Devel::REPL::Plugin::ReadLineHistory - Integrate history with the facilities provided by L<Term::ReadLine> =cut
The fixed code has been pushed to git. It should be available for the next release.
The problem was a little bit more than stated above. First, the Devel::REPL::Plugin::ReadLineHistory was loading and running. There were two problems: (1) the plugin only supported TR::Gnu (2) exit kills the shell before the WriteHistory is run as a result, I thought it was not working for me. I've just uploaded a new version of the ReadLineHistory plugin which, I believe, fully supports both Term::ReadLine::Gnu and Term::ReadLine::Perl. The plugin appears to work for win32 (TR::Perl) and cygwin (TR::Perl and TR::Gnu). The "death by exit" problem has been posted in another bug ticket. The initial work-around is planned to implement some sort of command for quitting the shell that can replace exit for our interactive use. --Chris