Show
Ignore:
Timestamp:
01/17/08 01:24:31 (10 months ago)
Author:
kana
Message:

lang/vim/textobj-user:
* Update the copyright notice.
* vim/dot.vim/autoload/textobj/user.vim:

  • textobj#user#move(): Modify to be able to use in Visual and
    Operator-pending mode.
  • textobj#user#select(): Fix the wrong selecting in Operator-pending mode.

* vim/dot.vim/doc/textobj-user.txt:

  • Update for the above changes.

* Mark as version 0.2.

Location:
lang/vim/textobj-user/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/vim/textobj-user/trunk/autoload/textobj/user.vim

    r2774 r4728  
    11" textobj-user - Support for user-defined text objects 
    2 " Version: 0.1 
    3 " Copyright (C) 2007 kana <http://nicht.s8.xrea.com/> 
     2" Version: 0.2 
     3" Copyright (C) 2007-2008 kana <http://nicht.s8.xrea.com/> 
    44" License: MIT license (see <http://www.opensource.org/licenses/mit-license>) 
    55" $Id$  "{{{1 
    66" Interfaces  "{{{1 
    77 
    8 function! textobj#user#move(pattern, flags) 
     8function! textobj#user#move(pattern, flags, previous_mode) 
     9  if a:previous_mode ==# 'v' 
     10    normal! gv 
     11  endif 
    912  let i = v:count1 
    1013  while 0 < i 
     
    2023" FIXME: In a case of a:pattern matches with one character. 
    2124function! textobj#user#select(pattern, flags, previous_mode) 
    22   execute 'normal!' "gv\<Esc>" 
     25  if a:previous_mode ==# 'v' 
     26    execute 'normal!' "gv\<Esc>" 
     27  endif 
    2328  let ORIG_POS = s:gpos_to_spos(getpos('.')) 
    2429 
     
    114119    for lhs in lhss 
    115120      if function_name == 'move-to-next' 
    116         execute 'nnoremap' s:mapargs_single_move(lhs, pat0, '') 
     121        execute 'nnoremap' s:mapargs_single_move(lhs, pat0, '', 'n') 
     122        execute 'vnoremap' s:mapargs_single_move(lhs, pat0, '', 'v') 
     123        execute 'onoremap' s:mapargs_single_move(lhs, pat0, '', 'o') 
    117124      elseif function_name == 'move-to-next-end' 
    118         execute 'nnoremap' s:mapargs_single_move(lhs, pat0, 'e') 
     125        execute 'nnoremap' s:mapargs_single_move(lhs, pat0, 'e', 'n') 
     126        execute 'vnoremap' s:mapargs_single_move(lhs, pat0, 'e', 'v') 
     127        execute 'onoremap' s:mapargs_single_move(lhs, pat0, 'e', 'o') 
    119128      elseif function_name == 'move-to-prev' 
    120         execute 'nnoremap' s:mapargs_single_move(lhs, pat0, 'b') 
     129        execute 'nnoremap' s:mapargs_single_move(lhs, pat0, 'b', 'n') 
     130        execute 'vnoremap' s:mapargs_single_move(lhs, pat0, 'b', 'v') 
     131        execute 'onoremap' s:mapargs_single_move(lhs, pat0, 'b', 'o') 
    121132      elseif function_name == 'move-to-prev-end' 
    122         execute 'nnoremap' s:mapargs_single_move(lhs, pat0, 'be') 
     133        execute 'nnoremap' s:mapargs_single_move(lhs, pat0, 'be', 'n') 
     134        execute 'vnoremap' s:mapargs_single_move(lhs, pat0, 'be', 'v') 
     135        execute 'onoremap' s:mapargs_single_move(lhs, pat0, 'be', 'o') 
    123136      elseif function_name == 'select-next' || function_name == 'select' 
    124137        execute 'vnoremap' s:mapargs_single_select(lhs, pat0, '', 'v') 
     
    214227 
    215228 
    216 function! s:mapargs_single_move(lhs, pattern, flags) 
    217   return printf('<silent> %s  :<C-u>call textobj#user#move(%s, %s)<CR>', 
    218               \ a:lhs, string(a:pattern), string(a:flags)) 
     229function! s:mapargs_single_move(lhs, pattern, flags, previous_mode) 
     230  return printf('<silent> %s  :<C-u>call textobj#user#move(%s, %s, %s)<CR>', 
     231              \ a:lhs, 
     232              \ string(a:pattern), string(a:flags), string(a:previous_mode)) 
    219233endfunction 
    220234 
  • lang/vim/textobj-user/trunk/doc/textobj-user.txt

    r2774 r4728  
    11*textobj-user.txt*      Support for user-defined text objects 
    22 
    3 Version 0.1 
    4 Copyright (C) 2007 kana <http://nicht.s8.xrea.com/> 
     3Version 0.2 
     4Copyright (C) 2007-2008 kana <http://nicht.s8.xrea.com/> 
    55License: MIT license (see <http://www.opensource.org/licenses/mit-license>) 
    66$Id$ 
     
    2525 
    2626                                                *textobj#user#move()* 
    27 textobj#user#move({pattern}, {flags}) 
     27textobj#user#move({pattern}, {flags}, {previous-mode}) 
    2828        Move the cursor to the appropriate object defined by {pattern}. 
    2929 
     
    3333                'b'     search backward instead of forward. 
    3434                'e'     move to the end of the match. 
     35 
     36        {previous-mode} is a string representing the "previous" mode, 
     37        that is, which mode of mapping causes the calling of this function. 
     38        For example, if this function is called via a mapping for 
     39        Operator-pending mode, {previous-mode} must be 'o'. 
     40                char    meaning ~ 
     41                ----    ------- ~ 
     42                'n'     Normal mode 
     43                'o'     Operator-pending mode 
     44                'v'     Visual mode 
    3545 
    3646        Return value is same as |searchpos()|. 
     
    4959                        cursor is not in the range of an object. 
    5060 
    51         {previous-mode} is a string that represents the "previous" mode. 
    52         For example, if this function is called via a mapping for 
    53         Operator-pending mode, {previous-mode} must be 'o'. 
    54                 char    meaning ~ 
    55                 ----    ------- ~ 
    56                 'o'     Operator-pending mode 
    57                 'v'     Visual mode 
     61        For the detail of {previous-mode}, see |textobj#user#move()|. 
    5862 
    5963        Return value is not defined. 
     
    7478                        {pattern1} and {pattern2}, this function does nothing. 
    7579 
    76         For the detail of {previous-mode}, see |textobj#user#select()|. 
     80        For the detail of {previous-mode}, see |textobj#user#move()|. 
    7781 
    7882        Return value is not defined. 
     
    128132CHANGELOG                                       *textobj-user-changelog* 
    129133 
     1340.2     2008-01-07T08:44:14+09:00 
     135        - textobj#user#select(): Fix the wrong selecting in Operator-pending 
     136          mode. 
     137        - textobj#user#move(): Modify to be able to use in Visual and 
     138          Operator-pending mode. 
     139 
    1301400.1     2007-11-16T01:17:45+09:00 
    131141        - Modify to be autoloaded.