From 061009db47d267772db1c95b8bfdcf31de97d343 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Fri, 8 Oct 2010 19:08:57 +0200 Subject: vim_mode: :map can map irssi commands. --- vim-mode/vim_mode.pl | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index ed348e4..fe54173 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -78,12 +78,13 @@ # # {lhs} is the key combination to be mapped, {rhs} the target. The <> notation # is used (e.g. is Ctrl-F), case is ignored. Supported <> keys: -# -, , , , . Mapping ex-mode command is -# supported. Only default mappings can be used in {rhs}. +# -, , , , . Mapping ex-mode and irssi commands +# is supported. Only default mappings can be used in {rhs}. # Examples: +# :map w W # to remap w to work like W # :map gb :bnext # to map gb to call :bnext # :map gB :bprev -# :map w W # to remap w to work like W +# :map /clear # map Ctrl-L to irssi command /clear # # # The following irssi settings are available: @@ -231,6 +232,8 @@ sub C_TEXTOBJECT () { 3 } sub C_INSERT () { 4 } # ex-mode commands sub C_EX () { 5 } +# irssi commands +sub C_IRSSI () { 6 } # word and non-word regex, keep in sync with setup_changed()! my $word = qr/[\w_]/o; @@ -1566,6 +1569,7 @@ sub ex_map { # Add new mapping. my $command; + # Ex-mode command if (index($rhs, ':') == 0) { $rhs = substr $rhs, 1; if (not exists $commands_ex->{$rhs}) { @@ -1573,6 +1577,13 @@ sub ex_map { } else { $command = $commands_ex->{$rhs}; } + # Irssi command + } elsif (index($rhs, '/') == 0) { + $command = { char => $rhs, + func => substr($rhs, 1), + type => C_IRSSI, + }; + # command-mode command } else { $rhs = _parse_mapping($2); if (not defined $rhs) { @@ -2017,6 +2028,11 @@ sub handle_command_cmd { print "Processing ex-command: $map->{char} ($cmd->{char})" if DEBUG; $cmd->{func}->($cmd->{char}); return 1; # call _stop() + # As can irssi commands. + } elsif ($cmd->{type} == C_IRSSI) { + print "Processing irssi-command: $map->{char} ($cmd->{char})" if DEBUG; + Irssi::command($cmd->{func}); + return 1; # call _stop(); } # text-objects (i a) are simulated with $movement -- cgit v1.2.3