Merge branch 'feature/regexp-find' into master

This commit is contained in:
haya14busa 2014-01-17 21:02:56 +09:00
commit 3c562d9572
3 changed files with 47 additions and 2 deletions

View File

@ -45,6 +45,7 @@ function! EasyMotion#reset()
let s:flag = { let s:flag = {
\ 'within_line' : 0, \ 'within_line' : 0,
\ 'dot_repeat' : 0, \ 'dot_repeat' : 0,
\ 'regexp' : 0,
\ } \ }
let s:current = { let s:current = {
\ 'is_operator' : 0, \ 'is_operator' : 0,
@ -321,8 +322,8 @@ function! EasyMotion#DotRepeat(visualmode) " {{{
let is_exclusive = s:previous.is_exclusive let is_exclusive = s:previous.is_exclusive
let s:current.is_operator = 1 let s:current.is_operator = 1
let s:flag.within_line = s:previous.line_flag let s:flag.within_line = s:previous.line_flag
for cnt in range(v:count1)
let s:flag.dot_repeat = 1 let s:flag.dot_repeat = 1
for cnt in range(v:count1)
silent call s:EasyMotion(re, direction, 0, is_exclusive) silent call s:EasyMotion(re, direction, 0, is_exclusive)
endfor endfor
endfunction " }}} endfunction " }}}
@ -456,6 +457,7 @@ endfunction " }}}
function! s:findMotion(num_strokes) "{{{ function! s:findMotion(num_strokes) "{{{
" Find Motion: S,F,T " Find Motion: S,F,T
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
let s:flag.regexp = a:num_strokes == -1 ? 1 : 0
let s:previous['input'] = get(s:previous, 'input', '') let s:previous['input'] = get(s:previous, 'input', '')
let input = EasyMotion#command_line#GetInput(a:num_strokes, s:previous.input) let input = EasyMotion#command_line#GetInput(a:num_strokes, s:previous.input)
@ -476,7 +478,7 @@ function! s:findMotion(num_strokes) "{{{
return re return re
endfunction "}}} endfunction "}}}
function! s:convertRegep(input) "{{{ function! s:convertRegep(input) "{{{
let re = escape(a:input, '.$^~\[]') let re = s:should_use_regexp() ? a:input : escape(a:input, '.$^~\[]')
if s:should_use_migemo(a:input) if s:should_use_migemo(a:input)
let re = s:convertMigemo(re) let re = s:convertMigemo(re)
@ -525,6 +527,9 @@ function! s:convertSmartcase(re, char) "{{{
return '\C' . re return '\C' . re
endif endif
endfunction "}}} endfunction "}}}
function! s:should_use_regexp() "{{{
return g:EasyMotion_use_regexp == 1 && s:flag.regexp == 1
endfunction "}}}
function! s:should_use_migemo(char) "{{{ function! s:should_use_migemo(char) "{{{
if ! g:EasyMotion_use_migemo || match(a:char, '\A') != -1 if ! g:EasyMotion_use_migemo || match(a:char, '\A') != -1
return 0 return 0

View File

@ -31,6 +31,7 @@ let g:EasyMotion_smartcase = get(g: , 'EasyMotion_smartcase' ,
let g:EasyMotion_skipfoldedline = get(g: , 'EasyMotion_skipfoldedline' , 1) let g:EasyMotion_skipfoldedline = get(g: , 'EasyMotion_skipfoldedline' , 1)
let g:EasyMotion_use_migemo = get(g: , 'EasyMotion_use_migemo' , 0) let g:EasyMotion_use_migemo = get(g: , 'EasyMotion_use_migemo' , 0)
let g:EasyMotion_use_upper = get(g: , 'EasyMotion_use_upper' , 0) let g:EasyMotion_use_upper = get(g: , 'EasyMotion_use_upper' , 0)
let g:EasyMotion_use_regexp = get(g: , 'EasyMotion_use_regexp' , 0)
let g:EasyMotion_enter_jump_first = get(g: , 'EasyMotion_enter_jump_first' , 0) let g:EasyMotion_enter_jump_first = get(g: , 'EasyMotion_enter_jump_first' , 0)
let g:EasyMotion_show_prompt = get(g: , 'EasyMotion_show_prompt' , 1) let g:EasyMotion_show_prompt = get(g: , 'EasyMotion_show_prompt' , 1)
let g:EasyMotion_prompt = let g:EasyMotion_prompt =

View File

@ -1091,5 +1091,44 @@ describe 'EasyMotion is jump motion'
end end
"}}} "}}}
" Regexp {{{
describe 'EasyMotion regexp'
before
new
let g:EasyMotion_keys = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
let g:EasyMotion_use_regexp = 1
map s <Plug>(easymotion-sn)
call EasyMotion#init()
call AddLine('poge1 2huga 3hiyo 4poyo')
" 12345678901234567890123
end
after
let g:EasyMotion_use_regexp = 0
close!
end
" <C-o> could jump back to previous location {{{
it 'provide regexp motion'
normal! 0
let l = line('.')
Expect CursorPos() == [l,1,'p']
exe "normal s\\d\<CR>a"
Expect CursorPos() == [l,5,'1']
normal! 0
Expect CursorPos() == [l,1,'p']
exe "normal s\\d\<CR>c"
Expect CursorPos() == [l,13,'3']
exe "normal s\$\<CR>a"
Expect CursorPos() == [l,23,'o']
exe "normal s\^\<CR>b"
Expect CursorPos() == [l,1,'p']
end
"}}}
end
"}}}
" vim: fdm=marker:et:ts=4:sw=4:sts=4 " vim: fdm=marker:et:ts=4:sw=4:sts=4