diff options
| author | dx | 2015-11-23 14:18:41 -0300 |
|---|---|---|
| committer | dx | 2015-11-23 14:18:41 -0300 |
| commit | 8d9d995b69ba2b436d4bd63061d8189a6844a9a8 (patch) | |
| tree | 0a8e939a47dbd15d9a8c04b61e21c1e33d6da738 /scripts/complete_at.pl | |
| parent | 2605878778636421276fe85cd9a2045d125546bd (diff) | |
| parent | 6dec1974e3ac2e71c26e842887a4b8fe2ec9082c (diff) | |
| download | scripts.irssi.org-8d9d995b69ba2b436d4bd63061d8189a6844a9a8.tar.bz2 | |
Merge pull request #173 from irssi/nei-scripts
FORCEFULLY ADD ALL THE SCRIPTS FROM NEI'S WEBSITE
Diffstat (limited to 'scripts/complete_at.pl')
| -rw-r--r-- | scripts/complete_at.pl | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/scripts/complete_at.pl b/scripts/complete_at.pl new file mode 100644 index 0000000..597e81e --- /dev/null +++ b/scripts/complete_at.pl @@ -0,0 +1,40 @@ +use strict; +use warnings; + +our $VERSION = '0.2'; # 49f841075725906 +our %IRSSI = ( + authors => 'Nei', + contact => 'Nei @ anti@conference.jabber.teamidiot.de', + url => "http://anti.teamidiot.de/", + name => 'complete_at', + description => 'Complete nicks after @ (twitter-style)', + license => 'ISC', + ); + +# Usage +# ===== +# write @ and type on the Tab key to complete nicks + +{ package Irssi::Nick } + +my $complete_char = '@'; + +sub complete_at { + my ($cl, $win, $word, $start, $ws) = @_; + if ($cl && !@$cl + && $win && $win->{active} + && $win->{active}->isa('Irssi::Channel')) { + if ((my $pos = rindex $word, $complete_char) > -1) { + my ($pre, $post) = ((substr $word, 0, $pos), (substr $word, $pos + 1)); + my $pre2 = length $start ? "$start $pre" : $pre; + my $pre3 = length $pre2 ? "$pre2$complete_char" : ""; + Irssi::signal_emit('complete word', $cl, $win, $post, $pre3, $ws); + unless (@$cl) { + push @$cl, grep { /^\Q$post/i } map { $_->{nick} } $win->{active}->nicks(); + } + map { $_ = "$pre$complete_char$_" } @$cl; + } + } +} + +Irssi::signal_add_last('complete word' => 'complete_at'); |
