File: Keywords.pm

package info (click to toggle)
libdevel-repl-perl 1.002001-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 256 kB
  • ctags: 185
  • sloc: perl: 2,323; makefile: 47
file content (26 lines) | stat: -rw-r--r-- 599 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package Devel::REPL::Plugin::CompletionDriver::Keywords;
use Devel::REPL::Plugin;
use B::Keywords qw/@Functions @Barewords/;
use namespace::clean -except => [ 'meta' ];

around complete => sub {
  my $orig = shift;
  my ($self, $text, $document) = @_;

  # recursively find the last element
  my $last = $document;
  while ($last->can('last_element') && defined($last->last_element)) {
      $last = $last->last_element;
  }

  return $orig->(@_)
    unless $last->isa('PPI::Token::Word');

  my $re = qr/^\Q$last/;

  return $orig->(@_),
         grep { $_ =~ $re } @Functions, @Barewords;
};

1;