summaryrefslogtreecommitdiffstats
path: root/scripts/special_complete.pl
blob: d8f06728a344c86e212ecb04dc190f0c8b5ed60b (plain)
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
27
28
29
30
use strict;
use vars qw($VERSION %IRSSI);
use Irssi;
$VERSION = '1.1';
%IRSSI = (
	authors  	=> 'Wouter Coekaerts',
	contact  	=> 'wouter@coekaerts.be, coekie@#irssi',
	name    	=> 'special_complete',
	description 	=> '(tab)complete irssi special variables (words that start with $) by evaluating them',
	license 	=> 'GPLv2',
	url     	=> 'http://wouter.coekaerts.be/irssi/',
	changed  	=> '28/07/03',
);

Irssi::signal_add_last 'complete word', sub {
	my ($complist, $window, $word, $linestart, $want_space) = @_;
	if ($word =~ /^\$/){
		my $evaluated;
		if (Irssi::active_win->{'active'}) {
			$evaluated = Irssi::active_win->{'active'}->parse_special($word);
		} elsif (Irssi::active_win->{'active_server'}) {
			$evaluated = Irssi::active_win->{'active_server'}->parse_special($word);
		} else {
			$evaluated = Irssi::parse_special($word);
		}
		if ($evaluated ne '') {
			push @$complist, $evaluated;
		}
	}
};