From a89e3f5572c010a02a498a542affb0c014c2807e Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 10 Oct 2010 00:35:23 +0200 Subject: vim_mode: Support counts with mapped ex-commands. --- vim-mode/vim_mode.pl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'vim-mode/vim_mode.pl') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 9d8e04b..fad440a 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -49,7 +49,9 @@ # * Switch split windows: Ctrl-W j Ctrl-W k # * Undo/Redo: u Ctrl-R # -# Counts and combinations work as well, e.g. d5fx or 3iabc +# Counts and combinations work as well, e.g. d5fx or 3iabc. Counts also +# work with mapped ex-commands (see below), e.g. if you map gb to do :bn, then +# 2gb will switch to the second next buffer. # Repeat also supports counts. # # The following insert mode mappings are supported: @@ -2121,7 +2123,15 @@ sub handle_command_cmd { # ex-mode command doesn't need any additional arguments. if ($cmd->{type} == C_EX) { print "Processing ex-command: $map->{char} ($cmd->{char})" if DEBUG; - $cmd->{func}->(substr $cmd->{char}, 1); + + if (not $numeric_prefix) { + $numeric_prefix = 1; + } + while ($numeric_prefix-- > 0) { + $cmd->{func}->(substr $cmd->{char}, 1); + } + $numeric_prefix = undef; + return 1; # call _stop() # As can irssi commands. } elsif ($cmd->{type} == C_IRSSI) { -- cgit v1.2.3 From fb0e4bbaaf74e9072b5af9d32f9fded2b4a0d50c Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 10 Oct 2010 00:36:22 +0200 Subject: vim_mode: Mapped irssi and commands reset count. --- vim-mode/vim_mode.pl | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'vim-mode/vim_mode.pl') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index fad440a..e866a23 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -2137,10 +2137,14 @@ sub handle_command_cmd { } elsif ($cmd->{type} == C_IRSSI) { print "Processing irssi-command: $map->{char} ($cmd->{char})" if DEBUG; Irssi::command($cmd->{func}); + + $numeric_prefix = undef; return 1; # call _stop(); # does nothing. } elsif ($cmd->{type} == C_NOP) { print "Processing : $map->{char}" if DEBUG; + + $numeric_prefix = undef; return 1; # call _stop(); } -- cgit v1.2.3 From 143ae36a262401892e6fff8f610375ed9c67ffdb Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 10 Oct 2010 01:05:22 +0200 Subject: vim_mode: Allow mappings with numbers. But not as the first key. --- vim-mode/vim_mode.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'vim-mode/vim_mode.pl') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index e866a23..181d854 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -2066,8 +2066,8 @@ sub handle_command_cmd { } # Counts - if (!$movement and ($char =~ m/[1-9]/ or - ($numeric_prefix && $char =~ m/[0-9]/))) { + if (!$movement and !$pending_map and + ($char =~ m/[1-9]/ or ($numeric_prefix && $char =~ m/[0-9]/))) { print "Processing numeric prefix: $char" if DEBUG; handle_numeric_prefix($char); return 1; # call _stop() -- cgit v1.2.3 From bb2167d04668a8537afdd3217d3786e353048eaa Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 10 Oct 2010 01:11:06 +0200 Subject: vim_mode: Support arguments to mapped ex-arguments. --- vim-mode/vim_mode.pl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'vim-mode/vim_mode.pl') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 181d854..879f0e0 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -92,6 +92,7 @@ # :map w W - to remap w to work like W # :map gb :bnext - to map gb to call :bnext # :map gB :bprev +# :map g1 :b 1 - to map g1 to switch to buffer 1 # :map /clear - map Ctrl-L to irssi command /clear # :map /window goto 1 # :map - disable , it does nothing now @@ -1616,11 +1617,14 @@ sub ex_map { my $command; # Ex-mode command if (index($rhs, ':') == 0) { - $rhs = substr $rhs, 1; - if (not exists $commands_ex->{$rhs}) { - return _warn_ex('map', "$2 not found"); + $rhs =~ /^:(\S+)(\s.+)?$/; + if (not exists $commands_ex->{$1}) { + return _warn_ex('map', "$rhs not found"); } else { - $command = $commands_ex->{$rhs}; + $command = { char => $rhs, + func => $commands_ex->{$1}->{func}, + type => C_EX, + }; } # Irssi command } elsif (index($rhs, '/') == 0) { @@ -2119,8 +2123,7 @@ sub handle_command_cmd { return 1; # call _stop() } - # Ex-mode commands can also be bound in command mode. Works only if the - # ex-mode command doesn't need any additional arguments. + # Ex-mode commands can also be bound in command mode. if ($cmd->{type} == C_EX) { print "Processing ex-command: $map->{char} ($cmd->{char})" if DEBUG; -- cgit v1.2.3 From b5f5fceb141736dcfb667f2d5935e0791b9546c6 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 10 Oct 2010 01:26:18 +0200 Subject: vim_mode: Whitespace only change. --- vim-mode/vim_mode.pl | 72 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 24 deletions(-) (limited to 'vim-mode/vim_mode.pl') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 879f0e0..1746c3b 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -385,30 +385,54 @@ my $commands # All available commands in Ex-Mode. my $commands_ex = { - s => { char => ':s', func => \&ex_substitute, type => C_EX }, - bnext => { char => ':bnext', func => \&ex_bnext, type => C_EX }, - bn => { char => ':bn', func => \&ex_bnext, type => C_EX }, - bprev => { char => ':bprev', func => \&ex_bprev, type => C_EX }, - bp => { char => ':bp', func => \&ex_bprev, type => C_EX }, - bdelete => { char => ':bdelete', func => \&ex_bdelete, type => C_EX }, - bd => { char => ':bd', func => \&ex_bdelete, type => C_EX }, - buffer => { char => ':buffer', func => \&ex_buffer, type => C_EX }, - b => { char => ':b', func => \&ex_buffer, type => C_EX }, - registers => { char => ':registers', func => \&ex_registers, type => C_EX }, - reg => { char => ':reg', func => \&ex_registers, type => C_EX }, - display => { char => ':display', func => \&ex_registers, type => C_EX }, - di => { char => ':di', func => \&ex_registers, type => C_EX }, - buffers => { char => ':buffer', func => \&ex_buffers, type => C_EX }, - ls => { char => ':ls', func => \&ex_buffers, type => C_EX }, - undolist => { char => ':undolist', func => \&ex_undolist, type => C_EX }, - undol => { char => ':undol', func => \&ex_undolist, type => C_EX }, - map => { char => ':map', func => \&ex_map, type => C_EX }, - unmap => { char => ':unmap', func => \&ex_unmap, type => C_EX }, - unm => { char => ':unm', func => \&ex_unmap, type => C_EX }, - source => { char => ':source', func => \&ex_source, type => C_EX }, - so => { char => ':so', func => \&ex_source, type => C_EX }, - mkvimrc => { char => ':mkvimrc', func => \&ex_mkvimrc, type => C_EX }, - mkv => { char => ':mkv', func => \&ex_mkvimrc, type => C_EX }, + s => { char => ':s', func => \&ex_substitute, + type => C_EX }, + bnext => { char => ':bnext', func => \&ex_bnext, + type => C_EX }, + bn => { char => ':bn', func => \&ex_bnext, + type => C_EX }, + bprev => { char => ':bprev', func => \&ex_bprev, + type => C_EX }, + bp => { char => ':bp', func => \&ex_bprev, + type => C_EX }, + bdelete => { char => ':bdelete', func => \&ex_bdelete, + type => C_EX }, + bd => { char => ':bd', func => \&ex_bdelete, + type => C_EX }, + buffer => { char => ':buffer', func => \&ex_buffer, + type => C_EX }, + b => { char => ':b', func => \&ex_buffer, + type => C_EX }, + registers => { char => ':registers', func => \&ex_registers, + type => C_EX }, + reg => { char => ':reg', func => \&ex_registers, + type => C_EX }, + display => { char => ':display', func => \&ex_registers, + type => C_EX }, + di => { char => ':di', func => \&ex_registers, + type => C_EX }, + buffers => { char => ':buffer', func => \&ex_buffers, + type => C_EX }, + ls => { char => ':ls', func => \&ex_buffers, + type => C_EX }, + undolist => { char => ':undolist', func => \&ex_undolist, + type => C_EX }, + undol => { char => ':undol', func => \&ex_undolist, + type => C_EX }, + map => { char => ':map', func => \&ex_map, + type => C_EX }, + unmap => { char => ':unmap', func => \&ex_unmap, + type => C_EX }, + unm => { char => ':unm', func => \&ex_unmap, + type => C_EX }, + source => { char => ':source', func => \&ex_source, + type => C_EX }, + so => { char => ':so', func => \&ex_source, + type => C_EX }, + mkvimrc => { char => ':mkvimrc', func => \&ex_mkvimrc, + type => C_EX }, + mkv => { char => ':mkv', func => \&ex_mkvimrc, + type => C_EX }, }; # MAPPINGS -- cgit v1.2.3 From 7d6d8c7f375ab15e587809773c3af014ed55135f Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 10 Oct 2010 01:51:23 +0200 Subject: vim_mode: Display command in statusbar after flushing pending map. Reported by estragib. --- vim-mode/vim_mode.pl | 1 + 1 file changed, 1 insertion(+) (limited to 'vim-mode/vim_mode.pl') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 1746c3b..4101579 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -2064,6 +2064,7 @@ sub flush_pending_map { $pending_map ne $old_pending_map; handle_command_cmd(undef); + Irssi::statusbar_items_redraw("vim_mode"); } sub handle_numeric_prefix { -- cgit v1.2.3 From d01581b027fa24fba5a0c1cd73667a1c1fa5a7bb Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 10 Oct 2010 02:47:09 +0200 Subject: vim_mode: Support counts with ex-commands. This supports e.g. :5b, :5bd, :bd 5. --- vim-mode/vim_mode.pl | 117 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 84 insertions(+), 33 deletions(-) (limited to 'vim-mode/vim_mode.pl') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 4101579..828f5a8 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -60,14 +60,14 @@ # # Ex-mode supports (activated by : in command mode) the following commands: # -# * Switching buffers: :b - switch to channel number -# :b# - switch to last channel +# * Switching buffers: :[N]b [N] - switch to channel number +# :b# - switch to last channel # :b # :b / # :buffer {args} (same as :b) -# :bn[ext] - switch to next window -# :bp[rev] - switch to previous window -# * Close window: :bd[elete] +# :[N]bn[ext] [N] - switch to next window +# :[N]bp[rev] [N] - switch to previous window +# * Close window: :[N]bd[elete] [N] # * Display windows: :ls :buffers # * Display registers: :reg[isters] {args} :di[splay] {args} # * Display undolist: :undol[ist] (mostly used for debugging) @@ -93,6 +93,7 @@ # :map gb :bnext - to map gb to call :bnext # :map gB :bprev # :map g1 :b 1 - to map g1 to switch to buffer 1 +# :map gb :b - to map gb to :b, 1gb switches to buffer 1, 5gb to 5 # :map /clear - map Ctrl-L to irssi command /clear # :map /window goto 1 # :map - disable , it does nothing now @@ -388,21 +389,21 @@ my $commands_ex s => { char => ':s', func => \&ex_substitute, type => C_EX }, bnext => { char => ':bnext', func => \&ex_bnext, - type => C_EX }, + type => C_EX, uses_count => 1 }, bn => { char => ':bn', func => \&ex_bnext, - type => C_EX }, + type => C_EX, uses_count => 1 }, bprev => { char => ':bprev', func => \&ex_bprev, - type => C_EX }, + type => C_EX, uses_count => 1 }, bp => { char => ':bp', func => \&ex_bprev, - type => C_EX }, + type => C_EX, uses_count => 1 }, bdelete => { char => ':bdelete', func => \&ex_bdelete, - type => C_EX }, + type => C_EX, uses_count => 1 }, bd => { char => ':bd', func => \&ex_bdelete, - type => C_EX }, + type => C_EX, uses_count => 1 }, buffer => { char => ':buffer', func => \&ex_buffer, - type => C_EX }, + type => C_EX, uses_count => 1 }, b => { char => ':b', func => \&ex_buffer, - type => C_EX }, + type => C_EX, uses_count => 1 }, registers => { char => ':registers', func => \&ex_registers, type => C_EX }, reg => { char => ':reg', func => \&ex_registers, @@ -1490,19 +1491,26 @@ sub _fix_input_pos { sub cmd_ex_command { my $arg_str = join '', @ex_buf; - if ($arg_str !~ /^([a-z]+)/) { + if ($arg_str !~ /^(\d*)?([a-z]+)/) { return _warn("Invalid Ex-mode command!"); } - if (not exists $commands_ex->{$1}) { - return _warn("Ex-mode $1 doesn't exist!"); + # Abort if command doesn't exist or used with count for unsupported + # commands. + if (not exists $commands_ex->{$2} or + ($1 ne '' and not $commands_ex->{$2}->{uses_count})) { + return _warn("Ex-mode $1$2 doesn't exist!"); } - $commands_ex->{$1}->{func}($arg_str); + my $count = $1; + if ($count eq '') { + $count = undef; + } + $commands_ex->{$2}->{func}($arg_str, $count); } sub ex_substitute { - my ($arg_str) = @_; + my ($arg_str, $count) = @_; # :s/// if ($arg_str =~ m|^s/(.+)/(.*)/([ig]*)|) { @@ -1538,25 +1546,67 @@ sub ex_substitute { } sub ex_bnext { - Irssi::command('window next'); + my ($arg_str, $count) = @_; + + if (not defined $count) { + if ($arg_str =~ /^bn(?:ext)?\s(\d+)$/) { + $count = $1; + } else { + $count = 1; + } + } + + while ($count-- > 0) { + Irssi::command('window next'); + } } sub ex_bprev { - Irssi::command('window previous'); + my ($arg_str, $count) = @_; + + if (not defined $count) { + if ($arg_str =~ /^bp(?:rev)?\s(\d+)$/) { + $count = $1; + } else { + $count = 1; + } + } + + while ($count-- > 0) { + Irssi::command('window previous'); + } } sub ex_bdelete { + my ($arg_str, $count) = @_; + + if (not defined $count) { + if ($arg_str =~ /^bd(?:elete)?\s(\d+)$/) { + $count = $1; + } + } + + if (defined $count) { + my $window = Irssi::window_find_refnum($count); + if (not $window) { + return; + } + $window->set_active(); + } Irssi::command('window close'); } sub ex_buffer { - my ($arg_str) = @_; + my ($arg_str, $count) = @_; # :b[buffer] {args} - if ($arg_str =~ m|^b(?:uffer)?\s*(.+)$|) { + if ($arg_str =~ m|^b(?:uffer)?\s*(.+)$| or defined $count) { my $window; my $item; my $buffer = $1; + # :[N]:b[uffer] + if (defined $count) { + $window = Irssi::window_find_refnum($count); # Go to window number. - if ($buffer =~ /^[0-9]+$/) { + } elsif ($buffer =~ /^[0-9]+$/) { $window = Irssi::window_find_refnum($buffer); # Go to previous window. } elsif ($buffer eq '#') { @@ -1588,7 +1638,7 @@ sub ex_buffer { } sub ex_registers { - my ($arg_str) = @_; + my ($arg_str, $count) = @_; # :reg[isters] {arg} and :di[splay] {arg} if ($arg_str =~ /^(?:reg(?:isters)?|di(?:splay)?)(?:\s+(.+)$)?/) { @@ -1618,15 +1668,19 @@ sub ex_registers { } sub ex_buffers { + my ($arg_str, $count) = @_; + Irssi::command('window list'); } sub ex_undolist { + my ($arg_str, $count) = @_; + _print_undo_buffer(); } sub ex_map { - my ($arg_str) = @_; + my ($arg_str, $count) = @_; # :map {lhs} {rhs} if ($arg_str =~ /^map (\S+) (\S.*)$/) { @@ -1692,7 +1746,7 @@ sub ex_map { } } sub ex_unmap { - my ($arg_str) = @_; + my ($arg_str, $count) = @_; # :unm[ap] {lhs} if ($arg_str !~ /^unm(?:ap)? (\S+)$/) { @@ -1757,6 +1811,8 @@ sub _parse_mapping_reverse { } sub ex_source { + my ($arg_str, $count) = @_; + # :so[urce], but only loads the vim_moderc file at the moment open my $file, '<', Irssi::get_irssi_dir() . '/vim_moderc' or return; @@ -1775,7 +1831,7 @@ sub ex_source { } sub ex_mkvimrc { - my ($arg_str) = @_; + my ($arg_str, $count) = @_; # :mkv[imrc][!], [file] not supported @@ -2152,12 +2208,7 @@ sub handle_command_cmd { if ($cmd->{type} == C_EX) { print "Processing ex-command: $map->{char} ($cmd->{char})" if DEBUG; - if (not $numeric_prefix) { - $numeric_prefix = 1; - } - while ($numeric_prefix-- > 0) { - $cmd->{func}->(substr $cmd->{char}, 1); - } + $cmd->{func}->(substr($cmd->{char}, 1), $numeric_prefix); $numeric_prefix = undef; return 1; # call _stop() -- cgit v1.2.3 From 34fd58554a4369523a02bde26bdd75bf09c76ff0 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 10 Oct 2010 03:13:22 +0200 Subject: vim_mode: Fix :bd from displaying buffers matching d. --- vim-mode/vim_mode.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'vim-mode/vim_mode.pl') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 828f5a8..2eefd66 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -1952,9 +1952,10 @@ sub b_windows_cb { my $windows = ''; - # A little code duplication of cmd_ex_command()! + # A little code duplication of cmd_ex_command(), but \s+ instead of \s* so + # :bd doesn't display buffers matching d. my $arg_str = join '', @ex_buf; - if ($arg_str =~ m|^b(?:uffer)?\s*(.+)$|) { + if ($arg_str =~ m|^b(?:uffer)?\s+(.+)$|) { my $buffer = $1; if ($buffer !~ /^[0-9]$/ and $buffer ne '#') { # Display matching windows. -- cgit v1.2.3 From 5e058e0b5780e504043c75fd5b0af6fca9f99d65 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 10 Oct 2010 03:18:39 +0200 Subject: vim_mode: Document :mapping ex-commands doesn't need . --- vim-mode/vim_mode.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'vim-mode/vim_mode.pl') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 2eefd66..17e7454 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -87,7 +87,8 @@ # {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 and irssi -# commands is supported. Only default mappings can be used in {rhs}. +# commands is supported. When mapping ex-mode commands the trailing is +# not necessary. 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 -- cgit v1.2.3 From def8af6d0454a8feae873d7df3afedb550807222 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 10 Oct 2010 03:40:37 +0200 Subject: vim_mode: Add known bug. --- vim-mode/vim_mode.pl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'vim-mode/vim_mode.pl') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 17e7454..f84c523 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -165,6 +165,9 @@ # Known bugs: # # * count before register doesn't work: e.g. 3"ap doesn't work, but "a3p does +# * mapping an incomplete ex-command doesn't open the ex-mode with the partial +# command (e.g. :map gb :b causes an error instead of opening the ex-mode +# and displaying :b) # * undo/redo positions are mostly wrong # # -- cgit v1.2.3 From b97f23c09096d3c40bf15417dad1f6a1e3c447c7 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 10 Oct 2010 03:42:29 +0200 Subject: vim_mode: :map {lhs} displays matching mappings. --- vim-mode/vim_mode.pl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'vim-mode/vim_mode.pl') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index f84c523..f2bd978 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -74,6 +74,7 @@ # * Source files :so[urce] - only sources vim_moderc at the moment, # {file} not supported # * Mappings: :map - display custom mappings +# :map {lhs} - display mappings starting with {lhs} # :map {lhs} {rhs} - add mapping # :unm[ap] {lhs} - remove custom mapping # * Save mappings: :mkv[imrc][!] - like in Vim, but [file] not supported @@ -1733,14 +1734,18 @@ sub ex_map { } add_map($lhs, $command); - # :map - } elsif ($arg_str eq 'map') { + # :map [lhs] + } elsif ($arg_str eq 'map' or $arg_str =~ /^map (\S+)$/) { + # Necessary for case insensitive matchings. lc alone won't work. + my $search = _parse_mapping_reverse(_parse_mapping($1)); + my $active_window = Irssi::active_win(); foreach my $key (sort keys %$maps) { my $map = $maps->{$key}; my $cmd = $map->{cmd}; if (defined $cmd) { next if $map->{char} eq $cmd->{char}; # skip default mappings + next if $map->{char} !~ /^\Q$search\E/; # skip non-matches $active_window->print(sprintf "%-15s %s", $map->{char}, $cmd->{char}); } -- cgit v1.2.3 From aee98a7b35bba8c93c027ed9042ff24f117e1b2e Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 10 Oct 2010 03:57:52 +0200 Subject: vim_mode: Add in command mode. is also mappable now. --- vim-mode/vim_mode.pl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'vim-mode/vim_mode.pl') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index f2bd978..77a4908 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -87,9 +87,9 @@ # # {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 and irssi -# commands is supported. When mapping ex-mode commands the trailing is -# not necessary. Only default mappings can be used in {rhs}. +# -, , , , , , . Mapping ex-mode and +# irssi commands is supported. When mapping ex-mode commands the trailing +# is not necessary. 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 @@ -278,9 +278,10 @@ my $commands repeatable => 1 }, # arrow like movement - h => { char => 'h', func => \&cmd_h, type => C_NORMAL }, - l => { char => 'l', func => \&cmd_l, type => C_NORMAL }, - ' ' => { char => '', func => \&cmd_l, type => C_NORMAL }, + h => { char => 'h', func => \&cmd_h, type => C_NORMAL }, + l => { char => 'l', func => \&cmd_l, type => C_NORMAL }, + "\x7F" => { char => '', func => \&cmd_h, type => C_NORMAL }, + ' ' => { char => '', func => \&cmd_l, type => C_NORMAL }, # history movement j => { char => 'j', func => \&cmd_j, type => C_NORMAL, no_operator => 1 }, @@ -1799,6 +1800,9 @@ sub _parse_mapping_bracket { # } elsif ($string eq 'cr') { $string = "\n"; + # + } elsif ($string eq 'bs') { + $string = chr(127); # Invalid char, return special string to recognize the error. } else { $string = ''; @@ -1811,6 +1815,7 @@ sub _parse_mapping_reverse { # Convert char to . $string =~ s/ //g; $string =~ s/\n//g; + $string =~ s/\x7F//g; # Convert Ctrl-X to . $string =~ s/([\x01-\x1A])/""/ge; # Convert Ctrl-6 and Ctrl-^ to . -- cgit v1.2.3 From a46cff6a006ce5c7488057432fa4e239e0d8519a Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 10 Oct 2010 04:07:09 +0200 Subject: vim_mode: Add to movement docs. --- vim-mode/vim_mode.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'vim-mode/vim_mode.pl') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 77a4908..e1e92f2 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -22,7 +22,7 @@ # * Insert/Command mode. Escape and Ctrl-C enter command mode. # /set vim_mode_cmd_seq j allows to use jj as Escape (any other character # can be used as well). -# * Cursor motion: h l 0 ^ $ f t F T +# * Cursor motion: h l 0 ^ $ f t F T # * History motion: j k gg G # gg moves to the oldest (first) history line. # G without a count moves to the current input line, with a count it goes to -- cgit v1.2.3 From 1b68997bf5ea9e2bfbb317a12ed9371ee478d494 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 10 Oct 2010 18:16:28 +0200 Subject: vim_mode: Fix B with operators. --- vim-mode/vim_mode.pl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'vim-mode/vim_mode.pl') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index e1e92f2..4fe334f 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -308,8 +308,7 @@ my $commands ge => { char => 'ge', func => \&cmd_ge, type => C_NORMAL, selection_needs_move_right => 1 }, W => { char => 'W', func => \&cmd_W, type => C_NORMAL }, - B => { char => 'B', func => \&cmd_B, type => C_NORMAL, - selection_needs_move_right => 1 }, + B => { char => 'B', func => \&cmd_B, type => C_NORMAL }, E => { char => 'E', func => \&cmd_E, type => C_NORMAL }, gE => { char => 'gE', func => \&cmd_gE, type => C_NORMAL, selection_needs_move_right => 1 }, -- cgit v1.2.3 From 8291c7aa38cebf5884e919c8a81e884e9b3bc809 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 10 Oct 2010 18:26:09 +0200 Subject: vim_mode: Correctly display pending text-objects. --- vim-mode/vim_mode.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'vim-mode/vim_mode.pl') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 4fe334f..3dbdebc 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -313,8 +313,8 @@ my $commands gE => { char => 'gE', func => \&cmd_gE, type => C_NORMAL, selection_needs_move_right => 1 }, # text-objects, leading _ means can't be mapped! - _i => { char => '_i', func => \&cmd__i, type => C_TEXTOBJECT }, - _a => { char => '_a', func => \&cmd__a, type => C_TEXTOBJECT }, + _i => { char => 'i', func => \&cmd__i, type => C_TEXTOBJECT }, + _a => { char => 'a', func => \&cmd__a, type => C_TEXTOBJECT }, # line movement '0' => { char => '0', func => \&cmd_0, type => C_NORMAL }, '^' => { char => '^', func => \&cmd_caret, type => C_NORMAL }, -- cgit v1.2.3 From 7f0cebd0197ebfd93d6b9c7c9f58c7dd10581e9f Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 10 Oct 2010 18:45:08 +0200 Subject: vim_mode: Fix pasting registers containing only "0". Reported by estragib. --- vim-mode/vim_mode.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'vim-mode/vim_mode.pl') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 3dbdebc..20562a7 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -561,7 +561,7 @@ sub insert_ctrl_r { my ($key) = @_; my $char = chr($key); - return if not defined $registers->{$char} or not $registers->{$char}; + return if not defined $registers->{$char} or $registers->{$char} eq ''; my $pos = _insert_at_position($registers->{$char}, 1, _input_pos()); _input_pos($pos + 1); @@ -1329,7 +1329,7 @@ sub cmd_P { sub _paste_at_position { my ($count, $pos) = @_; - return if not $registers->{$register}; + return if $registers->{$register} eq ''; return _insert_at_position($registers->{$register}, $count, $pos); } -- cgit v1.2.3 From ecf7327440954c61e65027b983489b76002a0436 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 10 Oct 2010 22:39:07 +0200 Subject: vim_mode: Fix warning when mapping :map. --- vim-mode/vim_mode.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'vim-mode/vim_mode.pl') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 20562a7..f9bb2ff 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -1737,7 +1737,9 @@ sub ex_map { # :map [lhs] } elsif ($arg_str eq 'map' or $arg_str =~ /^map (\S+)$/) { # Necessary for case insensitive matchings. lc alone won't work. - my $search = _parse_mapping_reverse(_parse_mapping($1)); + my $search = $1; + $search = '' if not defined $search; + $search = _parse_mapping_reverse(_parse_mapping($search)); my $active_window = Irssi::active_win(); foreach my $key (sort keys %$maps) { -- cgit v1.2.3