diff options
| author | Tom Feist <shabble@metavore.org> | 2010-09-27 19:39:55 +0000 | 
|---|---|---|
| committer | Tom Feist <shabble@metavore.org> | 2010-09-27 19:39:55 +0000 | 
| commit | 61201d51e788b9dce5cebc612814774f8af86cc0 (patch) | |
| tree | deeee72bd267b6e6008855e7fb8b1f1e61792ce8 | |
| parent | merged dev, fixed conflict over missing 'if DEBUG' (diff) | |
| download | irssi-scripts-61201d51e788b9dce5cebc612814774f8af86cc0.tar.gz irssi-scripts-61201d51e788b9dce5cebc612814774f8af86cc0.zip  | |
made commit_line use the most appropriate context (window item, window or
server) to execute commands, falling back to Irssi::command only if none of them
are available.
| -rw-r--r-- | vim-mode/vim_mode.pl | 27 | 
1 files changed, 25 insertions, 2 deletions
diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 58f402b..a8e1cbb 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -1100,13 +1100,36 @@ sub _commit_line {      return unless length $line; # ignore empty lines +    my $server = Irssi::active_server(); +    my $win = Irssi::active_win(); +    my $witem = ref $win ? $win->{active} : undef; + +    my $context; +    if (defined $witem) { +        $context = $witem; +    } elsif (defined $win) { +        $context = $win; +    } elsif (defined $server) { +        $context = $server; +    } else { +        $context = undef; +    } +      if ($line =~ /^[\Q$cmdchars\E]/) {          print "Committing line as command" if DEBUG; -        Irssi::command($line); +        if (defined $context) { +            $context->command($line); +        } else { +            Irssi::command($line); +        }      } else {          print "Committing line as text" if DEBUG; -        Irssi::command("/say $line"); +        if (defined $context) { +            $context->command("/say $line"); +        } else { +            Irssi::command("/say $line"); +        }      }  }  | 
