diff options
| author | Alexander Færøy | 2014-05-31 13:10:46 +0200 |
|---|---|---|
| committer | Alexander Færøy | 2014-05-31 13:10:46 +0200 |
| commit | 2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1 (patch) | |
| tree | 1c5e6d817c88e67b46e216a50e0aef5428bf63df /scripts/complete_lastspoke.pl | |
| parent | 2d080422d79d1fd49d6c5528593ccaaff9bfc583 (diff) | |
| download | scripts.irssi.org-2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1.tar.bz2 | |
Import scripts from scripts.irssi.org
Diffstat (limited to 'scripts/complete_lastspoke.pl')
| -rw-r--r-- | scripts/complete_lastspoke.pl | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/complete_lastspoke.pl b/scripts/complete_lastspoke.pl new file mode 100644 index 0000000..6556dc4 --- /dev/null +++ b/scripts/complete_lastspoke.pl @@ -0,0 +1,46 @@ +use strict; +use vars qw($VERSION %IRSSI); + +use Irssi; +$VERSION = '2.1'; +%IRSSI = ( + authors => 'Daenyth', + contact => 'Daenyth /at/ gmail /dot/ com', + name => 'Complete Last-Spoke', + description => 'When using tab completion on an empty input buffer, complete to the nick of the person who spoke most recently.', + license => 'GPL2', +); + +my %list_of_speakers; + +sub complete_to_last_nick { + my ($strings, $window, $word, $linestart, $want_space) = @_; + return unless ($linestart eq '' && $word eq ''); + + my $last_speaker = get_last_speaker($window); + return unless defined $last_speaker; + my $suffix = Irssi::settings_get_str('completion_char'); + @$strings = $last_speaker . $suffix; + $$want_space = 1; + Irssi::signal_stop(); +} + +sub get_last_speaker { + my $window = shift; + return $list_of_speakers{$window->{active}->{name}}; +} + +sub store_last_speaker { + my ($server, $message, $speaker, $address, $target) = @_; + $list_of_speakers{$target} = $speaker; +} + +sub store_last_actor { + my ($server, $args, $actor, $address, $target) = @_; + $list_of_speakers{$target} = $actor; +} + +Irssi::signal_add_first( 'complete word', \&complete_to_last_nick ); +Irssi::signal_add_last ( 'message public', \&store_last_speaker ); +Irssi::signal_add_last ( 'ctcp action', \&store_last_actor ); + |
