From cb830faff50530169eef1c932de56233b2f3c9c1 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Fri, 1 Oct 2010 18:12:33 +0200 Subject: vim_mode: First work on text-objects. They do nothing at the moment, but get (correctly) called. --- vim-mode/vim_mode.pl | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 4c91329..e861c71 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -297,6 +297,9 @@ my $movements 'W' => { func => \&cmd_movement_W }, 'B' => { func => \&cmd_movement_B }, 'E' => { func => \&cmd_movement_E }, + # text-objects + 'i_' => { func => \&cmd_movement_i_ }, + 'a_' => { func => \&cmd_movement_a_ }, # line movement '0' => { func => \&cmd_movement_0 }, '^' => { func => \&cmd_movement_caret }, @@ -768,6 +771,19 @@ sub _end_of_WORD { return $pos; } +sub cmd_movement_i_ { + my ($count, $pos, $repeat, $char) = @_; + + _warn("i_ not implemented yet"); + return; +} +sub cmd_movement_a_ { + my ($count, $pos, $repeat, $char) = @_; + + _warn("a_ not implemented yet"); + return; +} + sub cmd_movement_0 { _input_pos(0); return; @@ -1438,7 +1454,9 @@ sub handle_command_cmd { print "Processing numeric prefix: $char" if DEBUG; handle_numeric_prefix($char); - } elsif (!$movement && exists $movements_multiple->{$char}) { + # text-objects (i a) are simulated with $movement + } elsif (!$movement && (exists $movements_multiple->{$char} + or $operator and ($char eq 'i' or $char eq 'a'))) { print "Processing movement: $char" if DEBUG; $movement = $char; @@ -1527,6 +1545,10 @@ sub handle_command_cmd { # Use the real movement command (like t or f) for operator # below. $char = substr $movement, 0, 1; + # i_ and a_ represent text-objects. + if ($char eq 'i' or $char eq 'a') { + $char .= '_'; + } $return = $movements->{$char}->{func} ->($numeric_prefix, $cur_pos, $repeat, substr $movement, 1); -- cgit v1.2.3