From bba15b7b57a5c9c02585cb7d75c90a1e3493c4bb Mon Sep 17 00:00:00 2001 From: Craig Hammond Date: Sat, 31 Jan 2015 18:23:08 -0400 Subject: Prevent urls from generating spelling corrections. --- scripts/spellcheck.pl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/spellcheck.pl b/scripts/spellcheck.pl index 158ea3c..a4c5bf2 100644 --- a/scripts/spellcheck.pl +++ b/scripts/spellcheck.pl @@ -60,7 +60,7 @@ use vars qw($VERSION %IRSSI); use Irssi 20070804; use Text::Aspell; -$VERSION = '0.3'; +$VERSION = '0.4'; %IRSSI = ( authors => 'Jakub Jankowski', contact => 'shasta@toxcorp.com', @@ -171,10 +171,11 @@ sub spellcheck_key_pressed my $inputline = Irssi::parse_special('$L'); # check if inputline starts with any of cmdchars - # we shouldn't spellcheck commands + # or contains protocols, we shouldn't spellcheck either my $cmdchars = Irssi::settings_get_str('cmdchars'); - my $re = qr/^[$cmdchars]/; - return if ($inputline =~ $re); + my $cmdre = qr/^[$cmdchars]/; + my $protocolre = qr/[a-zA-Z]+:\/\/\S+/; + return if ($inputline =~ $cmdre or $inputline =~ $protocolre); # get last bit from the inputline my ($word) = $inputline =~ /\s*([^\s]+)$/; -- cgit v1.2.3 From 4e4d19eb64b3b3e6a40f48b4ca4df30cfecfe131 Mon Sep 17 00:00:00 2001 From: Craig Hammond Date: Sat, 31 Jan 2015 21:39:38 -0400 Subject: Will now skip checking urls but still check the rest of the words in the input. --- scripts/spellcheck.pl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/spellcheck.pl b/scripts/spellcheck.pl index a4c5bf2..349a20e 100644 --- a/scripts/spellcheck.pl +++ b/scripts/spellcheck.pl @@ -171,20 +171,23 @@ sub spellcheck_key_pressed my $inputline = Irssi::parse_special('$L'); # check if inputline starts with any of cmdchars - # or contains protocols, we shouldn't spellcheck either + # we shouldn't spellcheck commands my $cmdchars = Irssi::settings_get_str('cmdchars'); - my $cmdre = qr/^[$cmdchars]/; - my $protocolre = qr/[a-zA-Z]+:\/\/\S+/; - return if ($inputline =~ $cmdre or $inputline =~ $protocolre); + my $re = qr/^[$cmdchars]/; + return if ($inputline =~ $re); # get last bit from the inputline my ($word) = $inputline =~ /\s*([^\s]+)$/; + # do not spellcheck urls + my $re = qr/([a-zA-Z]+:\/\/\S+)|(^www)/; + return if ($word =~ $re); + # find appropriate language for current window item my $lang = spellcheck_find_language($win->{active_server}->{tag}, $win->{active}->{name}); my @suggestions = spellcheck_check_word($lang, $word, 0); - # Irssi::print("Debug: spellcheck_check_word($word) returned array of " . scalar @suggestions); + #Irssi::print("Debug: spellcheck_check_word($word) returned array of " . scalar @suggestions); return if (scalar @suggestions == 0); # we found a mistake, print suggestions -- cgit v1.2.3 From 2b5f93b005bfa0aa325d9ba3c4d0b64f2584f970 Mon Sep 17 00:00:00 2001 From: Craig Hammond Date: Sun, 1 Feb 2015 12:23:25 -0400 Subject: Both $re variables given distinct names. --- scripts/spellcheck.pl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/spellcheck.pl b/scripts/spellcheck.pl index 349a20e..cc81487 100644 --- a/scripts/spellcheck.pl +++ b/scripts/spellcheck.pl @@ -173,21 +173,21 @@ sub spellcheck_key_pressed # check if inputline starts with any of cmdchars # we shouldn't spellcheck commands my $cmdchars = Irssi::settings_get_str('cmdchars'); - my $re = qr/^[$cmdchars]/; - return if ($inputline =~ $re); + my $cmdre = qr/^[$cmdchars]/; + return if ($inputline =~ $cmdre); # get last bit from the inputline my ($word) = $inputline =~ /\s*([^\s]+)$/; # do not spellcheck urls - my $re = qr/([a-zA-Z]+:\/\/\S+)|(^www)/; - return if ($word =~ $re); + my $urlre = qr/(^[a-zA-Z]+:\/\/\S+)|(^www)/; + return if ($word =~ $urlre); # find appropriate language for current window item my $lang = spellcheck_find_language($win->{active_server}->{tag}, $win->{active}->{name}); my @suggestions = spellcheck_check_word($lang, $word, 0); - #Irssi::print("Debug: spellcheck_check_word($word) returned array of " . scalar @suggestions); + # Irssi::print("Debug: spellcheck_check_word($word) returned array of " . scalar @suggestions); return if (scalar @suggestions == 0); # we found a mistake, print suggestions -- cgit v1.2.3