Merge branch 'feature/enter_repeat' into master

This commit is contained in:
haya14busa 2014-01-14 11:40:18 +09:00
commit 348e381d23
3 changed files with 41 additions and 10 deletions

View File

@ -12,6 +12,7 @@ set cpo&vim
" == Init {{{ " == Init {{{
function! EasyMotion#init() function! EasyMotion#init()
" Init Migemo Dictionary " Init Migemo Dictionary
let s:old = {}
let s:migemo_dicts = {} let s:migemo_dicts = {}
let s:line_flag = 0 let s:line_flag = 0
" Anywhere regular expression: {{{ " Anywhere regular expression: {{{
@ -49,7 +50,9 @@ endfunction "}}}
" == Motion functions {{{ " == Motion functions {{{
" -- Find Motion ------------------------- " -- Find Motion -------------------------
function! EasyMotion#S(num_strokes, visualmode, direction) " {{{ function! EasyMotion#S(num_strokes, visualmode, direction) " {{{
let input = EasyMotion#command_line#GetInput(a:num_strokes) let s:old['input'] = get(s:old, 'input', '')
let input = EasyMotion#command_line#GetInput(a:num_strokes, s:old.input)
let s:old['input'] = input
" Check that we have an input char " Check that we have an input char
if empty(input) if empty(input)
@ -57,6 +60,8 @@ function! EasyMotion#S(num_strokes, visualmode, direction) " {{{
if ! empty(a:visualmode) if ! empty(a:visualmode)
silent exec 'normal! gv' silent exec 'normal! gv'
endif endif
redraw
echo ''
return return
endif endif
@ -65,7 +70,9 @@ function! EasyMotion#S(num_strokes, visualmode, direction) " {{{
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1)) call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1))
endfunction " }}} endfunction " }}}
function! EasyMotion#T(num_strokes, visualmode, direction) " {{{ function! EasyMotion#T(num_strokes, visualmode, direction) " {{{
let input = EasyMotion#command_line#GetInput(a:num_strokes) let s:old['input'] = get(s:old, 'input', '')
let input = EasyMotion#command_line#GetInput(a:num_strokes, s:old.input)
let s:old['input'] = input
" Check that we have an input char " Check that we have an input char
if empty(input) if empty(input)
@ -73,6 +80,8 @@ function! EasyMotion#T(num_strokes, visualmode, direction) " {{{
if ! empty(a:visualmode) if ! empty(a:visualmode)
silent exec 'normal! gv' silent exec 'normal! gv'
endif endif
redraw
echo ''
return return
endif endif
@ -120,7 +129,9 @@ function! EasyMotion#JumpToAnywhere(visualmode, direction) " {{{
endfunction " }}} endfunction " }}}
" -- Line Motion ------------------------- " -- Line Motion -------------------------
function! EasyMotion#SL(num_strokes, visualmode, direction) " {{{ function! EasyMotion#SL(num_strokes, visualmode, direction) " {{{
let input = EasyMotion#command_line#GetInput(a:num_strokes) let s:old['input'] = get(s:old, 'input', '')
let input = EasyMotion#command_line#GetInput(a:num_strokes, s:old.input)
let s:old['input'] = input
" Check that we have an input char " Check that we have an input char
if empty(input) if empty(input)
@ -128,6 +139,8 @@ function! EasyMotion#SL(num_strokes, visualmode, direction) " {{{
if ! empty(a:visualmode) if ! empty(a:visualmode)
silent exec 'normal! gv' silent exec 'normal! gv'
endif endif
redraw
echo ''
return return
endif endif
@ -137,7 +150,9 @@ function! EasyMotion#SL(num_strokes, visualmode, direction) " {{{
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1)) call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1))
endfunction " }}} endfunction " }}}
function! EasyMotion#TL(num_strokes, visualmode, direction) " {{{ function! EasyMotion#TL(num_strokes, visualmode, direction) " {{{
let input = EasyMotion#command_line#GetInput(a:num_strokes) let s:old['input'] = get(s:old, 'input', '')
let input = EasyMotion#command_line#GetInput(a:num_strokes, s:old.input)
let s:old['input'] = input
" Check that we have an input char " Check that we have an input char
if empty(input) if empty(input)
@ -145,6 +160,8 @@ function! EasyMotion#TL(num_strokes, visualmode, direction) " {{{
if ! empty(a:visualmode) if ! empty(a:visualmode)
silent exec 'normal! gv' silent exec 'normal! gv'
endif endif
redraw
echo ''
return return
endif endif
@ -326,7 +343,7 @@ endfunction " }}}
" -- Repeat Motion ----------------------- " -- Repeat Motion -----------------------
function! EasyMotion#Repeat(visualmode) " {{{ function! EasyMotion#Repeat(visualmode) " {{{
" Repeat previous motion with previous targets " Repeat previous motion with previous targets
if ! exists('s:old') if s:old ==# {}
call s:Message("Previous targets doesn't exist") call s:Message("Previous targets doesn't exist")
return return
endif endif
@ -1013,10 +1030,8 @@ function! s:EasyMotion(regexp, direction, visualmode, mode, ...) " {{{
let targets = [] let targets = []
" Store Regular Expression " Store Regular Expression
let s:old = { let s:old['regexp'] = a:regexp
\ 'regexp': a:regexp, let s:old['direction'] = a:direction
\ 'direction': a:direction,
\ }
let s:old['line_flag'] = s:line_flag == 1 ? 1 : 0 let s:old['line_flag'] = s:line_flag == 1 ? 1 : 0
try try

View File

@ -40,7 +40,9 @@ function! s:Cancell() " {{{
return '' return ''
endfunction " }}} endfunction " }}}
function! EasyMotion#command_line#GetInput(num_strokes) "{{{ function! EasyMotion#command_line#GetInput(num_strokes, ...) "{{{
let previous_input = a:0 == 1 ? a:1 : ''
let input = '' let input = ''
" repeat a:num_strokes times " repeat a:num_strokes times
let prompt_num = a:num_strokes < 50 ? a:num_strokes : '' let prompt_num = a:num_strokes < 50 ? a:num_strokes : ''
@ -72,7 +74,14 @@ function! EasyMotion#command_line#GetInput(num_strokes) "{{{
elseif EasyMotion#command_line#is_input("\<C-w>") elseif EasyMotion#command_line#is_input("\<C-w>")
" Delete word " Delete word
let input = matchstr(input, '^\zs.\{-}\ze\(\(\w*\)\|\(.\)\)$') let input = matchstr(input, '^\zs.\{-}\ze\(\(\w*\)\|\(.\)\)$')
elseif EasyMotion#command_line#is_input("\<C-p>")
let input = previous_input
elseif EasyMotion#command_line#is_input("\<C-n>")
let input = ''
elseif EasyMotion#command_line#is_input("\<CR>") elseif EasyMotion#command_line#is_input("\<CR>")
if len(input) == 0
return previous_input
endif
" Return input charcters " Return input charcters
return input return input
elseif EasyMotion#command_line#is_input("\<C-j>") elseif EasyMotion#command_line#is_input("\<C-j>")

View File

@ -248,6 +248,13 @@ Repeat ~
Repeat last motion type including input target character. Repeat last motion type including input target character.
Nothing will happen when previous motion doesn't exist. Nothing will happen when previous motion doesn't exist.
Last Find Motion~
In Find motion (e.g. |<Plug>(easymoion-s)| ), to type `<CR>`
without input characters invoke last find motion. This
does not repeat motion type (e.g. othrer word motion,
<Plug>(easymotion-j) etc...) but only repeat input
characters.
Within line motion ~ Within line motion ~
*easymotion-within-line* *easymotion-within-line*