aboutsummaryrefslogtreecommitdiffstats
path: root/tinyurl-tabcomplete/complete-tiny-url.pl
diff options
context:
space:
mode:
authorTom Feist <shabble@cowu.be>2010-09-16 14:08:25 +0000
committerTom Feist <shabble@cowu.be>2010-09-16 14:08:25 +0000
commit35f46bb0515352c71d81d5ec13b51f96f2b8f9ef (patch)
treefab8f0cbd90d4140bd01f82e2e2d54089f36acca /tinyurl-tabcomplete/complete-tiny-url.pl
parentadded some requests for help notes to the index page (diff)
downloadirssi-scripts-35f46bb0515352c71d81d5ec13b51f96f2b8f9ef.tar.gz
irssi-scripts-35f46bb0515352c71d81d5ec13b51f96f2b8f9ef.zip
added a script to tab-complete URIs into their tinified equivalents
Diffstat (limited to 'tinyurl-tabcomplete/complete-tiny-url.pl')
-rw-r--r--tinyurl-tabcomplete/complete-tiny-url.pl29
1 files changed, 29 insertions, 0 deletions
diff --git a/tinyurl-tabcomplete/complete-tiny-url.pl b/tinyurl-tabcomplete/complete-tiny-url.pl
new file mode 100644
index 0000000..def9440
--- /dev/null
+++ b/tinyurl-tabcomplete/complete-tiny-url.pl
@@ -0,0 +1,29 @@
+use strict;
+use vars qw($VERSION %IRSSI);
+
+use Irssi;
+use Regexp::Common qw/URI/;
+use WWW::Shorten::TinyURL;
+
+$VERSION = '2.1';
+%IRSSI = (
+ authors => 'Shabble',
+ contact => 'shabble+irssi /at/ metavore /dot/ org',
+ name => 'Shorten URLs using Tab',
+ description => '',
+ license => 'WTFPL',
+);
+
+sub do_complete {
+ my ($strings, $window, $word, $linestart, $want_space) = @_;
+ return if $word eq '';
+ if ($word =~ m/$RE{URI}{HTTP}{-keep}/) {
+ my $uri = makeashorterlink($1);
+ push @$strings, $uri if $uri;
+ $$want_space = 1;
+ Irssi::signal_stop();
+ }
+}
+
+Irssi::signal_add_first( 'complete word', \&do_complete);
+