diff options
author | Tom Feist <shabble@metavore.org> | 2010-09-27 21:27:11 +0000 |
---|---|---|
committer | Tom Feist <shabble@metavore.org> | 2010-09-27 21:27:11 +0000 |
commit | 5811413f9ffbc8a6b5af43b9e5fa20154b2d6581 (patch) | |
tree | 9a0dafe34fdca56ad7688297406e311693fb4f27 /vim-mode | |
parent | vim_mode: Add support for utf-8 manipulation, on by default. (diff) | |
download | irssi-scripts-5811413f9ffbc8a6b5af43b9e5fa20154b2d6581.tar.gz irssi-scripts-5811413f9ffbc8a6b5af43b9e5fa20154b2d6581.zip |
changed word and non_word variables to use pre-compiled regex patterns rather
than strings.
Diffstat (limited to 'vim-mode')
-rw-r--r-- | vim-mode/vim_mode.pl | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index ef38daf..0aa6b61 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -75,9 +75,8 @@ sub M_INS() { 0 } # insert mode sub M_EX () { 2 } # extended mode (after a :?) # word and non-word regex -my $word = '[\w_]'; -my $non_word = '[^\w_\s]'; - +my $word = qr/[\w_]/o; +my $non_word = qr/[^\w_\s]/o; # GLOBAL VARIABLES @@ -1068,7 +1067,15 @@ sub setup_changed { $DEBUG_ENABLED = Irssi::settings_get_bool('vim_mode_debug'); - $utf8 = Irssi::settings_get_bool('vim_mode_utf8'); + my $new_utf8 = Irssi::settings_get_bool('vim_mode_utf8'); + + if ($new_utf8 != $utf8) { + # recompile the patterns when switching to/from utf-8 + $word = qr/[\w_]/o; + $non_word = qr/[^\w_\s]/o; + } + + $utf8 = $new_utf8; } sub UNLOAD { |