daverowntree has asked for the wisdom of the Perl Monks concerning the following question:

This subject has been 'answered' on various web resources, but I don't find it works for me; I get an extra space after tab-completion, using Term::ReadLine::Gnu even though I set the attribute 'completion_suppress_append' which allegedly works for Gnu readline. Well, it won't work for me on cygwin (latest 32-bit release) with perl 5.14.12. I can't tell if this is a cygwin issue or a perl issue - any ideas how to debug? - it's driving me potty!
use Term::ReadLine; my @commands = qw(one two three four five six seven eight nine ten); my $term = Term::ReadLine->new('test'); if (my $attr = $term->Attribs) { my $pkg = Term::ReadLine->ReadLine(); print "package is $pkg\n"; $term->ornaments(0); $attr->{basic_word_break_characters} = ". \t\n"; $attr->{completer_word_break_characters} = " \t\n"; $attr->{completion_function} = \&complete_word; $attr->{completion_suppress_append} = 1; # doesn't work! :( $attr->{completion_append_character} = "\0"; # nor this } while (1) { my $Command = $term->readline("Cmd>"); print "command:>$Command<\n"; } sub complete_word { my ($text, $line, $start) = @_; return grep(/^$text/, @commands); }
TIA!

Replies are listed 'Best First'.
Re: term::readline::gnu extra spaces on completion
by Eily (Monsignor) on Feb 03, 2014 at 17:38 UTC

    Are you sure you are actually running Term::Readline::Gnu? Unless $ENV{PERL_RL} specifies ortherwise, Term::ReadLine indeed tries to use Term::ReadLine::Gnu first, then the EditLine version if it failed, then the Perl version, and at last if all else failed, defaults to Term::ReadLine::Stub where Attribs is defined as : sub Attribs { {} }

    Try printing @Term::ReadLine::ISA or the output of Term::ReadLine::Readline() to see which version you are actually using.

      Thanks for you suggestions:
      use Term::ReadLine; my $pkg = Term::ReadLine->ReadLine(); print "Term::ReadLine->ReadLine() says \'$pkg\'\n"; my $pkg2 = $ENV{PERL_RL}; print "ENV(PERL_RL) says \'$pkg2\'\n"; print "\@Term::ReadLine::ISA says ", @Term::ReadLine::ISA, "\n";
      gives:

      $ perl ../Tools/term_check.pl
      Term::ReadLine->ReadLine() says 'Term::ReadLine::Gnu'
      ENV(PERL_RL) says ''
      @Term::ReadLine::ISA says Term::ReadLine::GnuTerm::ReadLine::Stub

      So, as far as I can tell, I am running the Gnu version.

        Hmm ... You could check the version of your GRL, it has to be higher than 4.3 for rl_completion_suppress_append to work.

        I don't have any more ideas after that I'm afraid.