# irssi-script dont_plenk.pl

# Description
# Helps you to avoid plenking;
# Problem:
#  Nick is in the channel, you type
#  `hey ni<tab>, how are you?'
#  normally gets
#  `hey Nick , how are you?'
# Solution:
#  dont_plenk.pl suppresses the space in normal text, you get a space after
#  /commands and at the beginning of the line (Nick: ).

use strict;
use Irssi;
use vars qw($VERSION %IRSSI);


$VERSION = "0.5";
%IRSSI = (
          name        => 'dont_plenk',
          authors     => 'Wolfgang Kroener',
          contact     => 'http://www.azog.de/impressum.shtml',
          url         => 'http://www.azog.de/irssi/dont_plenk.pl',
          license     => 'GPL',
          description => 'suppresses the space after tab-completion: avoid "nick ,", you get a space on the beginning of the line (nick: ) and after a /command',
         );

sub sig_complete_word ($$$$$) {
    my ($list, $window, $word, $linestart, $want_space) = @_;
    #don't suppress after a command
    $linestart =~ s/^\/\w+//i;
    #don't suppress after an option of a command (/msg -ircnet foo nick)
    $linestart =~ s/^-\w+//i;
    if ($linestart ne "") {
       $$want_space = 0;
    }
}


Irssi::signal_add_first('complete word', \&sig_complete_word);

