1 # First cut at using the readline history directly rather than reimplementing
2 # it. It does save history but it's a little crappy; still playing with it ;)
4 # epitaph, 22nd April 2007
6 package Devel::REPL::Plugin::ReadLineHistory;
8 use Devel::REPL::Plugin;
12 my $hist_file = $ENV{PERLREPL_HISTFILE} ||
13 File::Spec->catfile(File::HomeDir->my_home, '.perlreplhist');
15 # HISTLEN should probably be in a config file to stop people accidentally
16 # truncating their history if they start the program and forget to set
18 my $hist_len=$ENV{PERLREPL_HISTLEN} || 100;
23 if ($self->term->ReadLine eq 'Term::ReadLine::Gnu') {
24 $self->term->stifle_history($hist_len);
26 if ($self->term->ReadLine eq 'Term::ReadLine::Perl') {
27 $self->term->Attribs->{MaxHistorySize} = $hist_len;
29 -f($hist_file) && $self->term->ReadHistory($hist_file);
30 $self->term->Attribs->{do_expand}=1;
32 $self->term->WriteHistory($hist_file) ||
33 $self->print("warning: failed to write history file $hist_file");
42 Devel::REPL::Plugin::ReadLineHistory - Integrate history with the facilities provided by L<Term::ReadLine>