Use is_exclusive instead of mode(1)
This commit is contained in:
parent
b130898848
commit
32a7e1a8b7
@ -54,6 +54,9 @@ function! EasyMotion#S(num_strokes, visualmode, direction) " {{{
|
|||||||
let input = EasyMotion#command_line#GetInput(a:num_strokes, s:previous.input)
|
let input = EasyMotion#command_line#GetInput(a:num_strokes, s:previous.input)
|
||||||
let s:previous['input'] = input
|
let s:previous['input'] = input
|
||||||
|
|
||||||
|
let mode = mode(1)
|
||||||
|
let is_exclusive = mode ==# 'no' ? 1 : 0
|
||||||
|
|
||||||
" Check that we have an input char
|
" Check that we have an input char
|
||||||
if empty(input)
|
if empty(input)
|
||||||
" Restore selection
|
" Restore selection
|
||||||
@ -67,13 +70,16 @@ function! EasyMotion#S(num_strokes, visualmode, direction) " {{{
|
|||||||
|
|
||||||
let re = s:findMotion(input)
|
let re = s:findMotion(input)
|
||||||
|
|
||||||
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1))
|
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_exclusive)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! EasyMotion#T(num_strokes, visualmode, direction) " {{{
|
function! EasyMotion#T(num_strokes, visualmode, direction) " {{{
|
||||||
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)
|
||||||
let s:previous['input'] = input
|
let s:previous['input'] = input
|
||||||
|
|
||||||
|
let mode = mode(1)
|
||||||
|
let is_exclusive = mode ==# 'no' ? 1 : 0
|
||||||
|
|
||||||
" Check that we have an input char
|
" Check that we have an input char
|
||||||
if empty(input)
|
if empty(input)
|
||||||
" Restore selection
|
" Restore selection
|
||||||
@ -95,37 +101,40 @@ function! EasyMotion#T(num_strokes, visualmode, direction) " {{{
|
|||||||
let re = '.\ze' . re
|
let re = '.\ze' . re
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1))
|
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_exclusive)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
" -- Word Motion -------------------------
|
" -- Word Motion -------------------------
|
||||||
function! EasyMotion#WB(visualmode, direction) " {{{
|
function! EasyMotion#WB(visualmode, direction) " {{{
|
||||||
call s:EasyMotion('\(\<.\|^$\)', a:direction, a:visualmode ? visualmode() : '', '')
|
call s:EasyMotion('\(\<.\|^$\)', a:direction, a:visualmode ? visualmode() : '', 0)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! EasyMotion#WBW(visualmode, direction) " {{{
|
function! EasyMotion#WBW(visualmode, direction) " {{{
|
||||||
call s:EasyMotion('\(\(^\|\s\)\@<=\S\|^$\)', a:direction, a:visualmode ? visualmode() : '', '')
|
call s:EasyMotion('\(\(^\|\s\)\@<=\S\|^$\)', a:direction, a:visualmode ? visualmode() : '', 0)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! EasyMotion#E(visualmode, direction) " {{{
|
function! EasyMotion#E(visualmode, direction) " {{{
|
||||||
call s:EasyMotion('\(.\>\|^$\)', a:direction, a:visualmode ? visualmode() : '', mode(1))
|
let is_exclusive = mode(1) ==# 'no' ? 1 : 0
|
||||||
|
call s:EasyMotion('\(.\>\|^$\)', a:direction, a:visualmode ? visualmode() : '', is_exclusive)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! EasyMotion#EW(visualmode, direction) " {{{
|
function! EasyMotion#EW(visualmode, direction) " {{{
|
||||||
call s:EasyMotion('\(\S\(\s\|$\)\|^$\)', a:direction, a:visualmode ? visualmode() : '', mode(1))
|
let is_exclusive = mode(1) ==# 'no' ? 1 : 0
|
||||||
|
call s:EasyMotion('\(\S\(\s\|$\)\|^$\)', a:direction, a:visualmode ? visualmode() : '', is_exclusive)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
" -- JK Motion ---------------------------
|
" -- JK Motion ---------------------------
|
||||||
function! EasyMotion#JK(visualmode, direction) " {{{
|
function! EasyMotion#JK(visualmode, direction) " {{{
|
||||||
|
"FIXME: support exclusive
|
||||||
if g:EasyMotion_startofline
|
if g:EasyMotion_startofline
|
||||||
call s:EasyMotion('^\(\w\|\s*\zs\|$\)', a:direction, a:visualmode ? visualmode() : '', '')
|
call s:EasyMotion('^\(\w\|\s*\zs\|$\)', a:direction, a:visualmode ? visualmode() : '', 0)
|
||||||
else
|
else
|
||||||
let prev_column = getpos('.')[2] - 1
|
let prev_column = getpos('.')[2] - 1
|
||||||
call s:EasyMotion('^.\{,' . prev_column . '}\zs\(.\|$\)', a:direction, a:visualmode ? visualmode() : '', '')
|
call s:EasyMotion('^.\{,' . prev_column . '}\zs\(.\|$\)', a:direction, a:visualmode ? visualmode() : '', 0)
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
" -- Search Motion -----------------------
|
" -- Search Motion -----------------------
|
||||||
function! EasyMotion#Search(visualmode, direction) " {{{
|
function! EasyMotion#Search(visualmode, direction) " {{{
|
||||||
call s:EasyMotion(@/, a:direction, a:visualmode ? visualmode() : '', '')
|
call s:EasyMotion(@/, a:direction, a:visualmode ? visualmode() : '', 0)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
" -- JumpToAnywhere Motion ---------------
|
" -- JumpToAnywhere Motion ---------------
|
||||||
function! EasyMotion#JumpToAnywhere(visualmode, direction) " {{{
|
function! EasyMotion#JumpToAnywhere(visualmode, direction) " {{{
|
||||||
call s:EasyMotion( g:EasyMotion_re_anywhere, a:direction, a:visualmode ? visualmode() : '', '')
|
call s:EasyMotion( g:EasyMotion_re_anywhere, a:direction, a:visualmode ? visualmode() : '', 0)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
" -- Line Motion -------------------------
|
" -- Line Motion -------------------------
|
||||||
function! EasyMotion#SL(num_strokes, visualmode, direction) " {{{
|
function! EasyMotion#SL(num_strokes, visualmode, direction) " {{{
|
||||||
@ -133,6 +142,9 @@ function! EasyMotion#SL(num_strokes, visualmode, direction) " {{{
|
|||||||
let input = EasyMotion#command_line#GetInput(a:num_strokes, s:previous.input)
|
let input = EasyMotion#command_line#GetInput(a:num_strokes, s:previous.input)
|
||||||
let s:previous['input'] = input
|
let s:previous['input'] = input
|
||||||
|
|
||||||
|
|
||||||
|
let is_exclusive = mode(1) ==# 'no' ? 1 : 0
|
||||||
|
|
||||||
" Check that we have an input char
|
" Check that we have an input char
|
||||||
if empty(input)
|
if empty(input)
|
||||||
" Restore selection
|
" Restore selection
|
||||||
@ -148,13 +160,15 @@ function! EasyMotion#SL(num_strokes, visualmode, direction) " {{{
|
|||||||
|
|
||||||
let re = s:findMotion(input)
|
let re = s:findMotion(input)
|
||||||
|
|
||||||
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1))
|
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_exclusive)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! EasyMotion#TL(num_strokes, visualmode, direction) " {{{
|
function! EasyMotion#TL(num_strokes, visualmode, direction) " {{{
|
||||||
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)
|
||||||
let s:previous['input'] = input
|
let s:previous['input'] = input
|
||||||
|
|
||||||
|
let is_exclusive = mode(1) ==# 'no' ? 1 : 0
|
||||||
|
|
||||||
" Check that we have an input char
|
" Check that we have an input char
|
||||||
if empty(input)
|
if empty(input)
|
||||||
" Restore selection
|
" Restore selection
|
||||||
@ -178,33 +192,34 @@ function! EasyMotion#TL(num_strokes, visualmode, direction) " {{{
|
|||||||
let re = '.\ze' . re
|
let re = '.\ze' . re
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1))
|
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_exclusive)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! EasyMotion#WBL(visualmode, direction) " {{{
|
function! EasyMotion#WBL(visualmode, direction) " {{{
|
||||||
let s:line_flag = 1
|
let s:line_flag = 1
|
||||||
call s:EasyMotion('\(\<.\|^$\)', a:direction, a:visualmode ? visualmode() : '', '')
|
call s:EasyMotion('\(\<.\|^$\)', a:direction, a:visualmode ? visualmode() : '', 0)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! EasyMotion#EL(visualmode, direction) " {{{
|
function! EasyMotion#EL(visualmode, direction) " {{{
|
||||||
let s:line_flag = 1
|
let s:line_flag = 1
|
||||||
call s:EasyMotion('\(.\>\|^$\)', a:direction, a:visualmode ? visualmode() : '', mode(1))
|
let is_exclusive = mode(1) ==# 'no' ? 1 : 0
|
||||||
|
call s:EasyMotion('\(.\>\|^$\)', a:direction, a:visualmode ? visualmode() : '', is_exclusive)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! EasyMotion#LineAnywhere(visualmode, direction) " {{{
|
function! EasyMotion#LineAnywhere(visualmode, direction) " {{{
|
||||||
let s:line_flag = 1
|
let s:line_flag = 1
|
||||||
let re = g:EasyMotion_re_line_anywhere
|
let re = g:EasyMotion_re_line_anywhere
|
||||||
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', '')
|
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', 0)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
" -- Special Motion ----------------------
|
" -- Special Motion ----------------------
|
||||||
function! EasyMotion#SelectLines() "{{{
|
function! EasyMotion#SelectLines() "{{{
|
||||||
let orig_pos = [line('.'), col('.')]
|
let orig_pos = [line('.'), col('.')]
|
||||||
|
|
||||||
call s:EasyMotion('^\(\w\|\s*\zs\|$\)', 2, '', '', 0, 0, 1)
|
call s:EasyMotion('^\(\w\|\s*\zs\|$\)', 2, '', 0, 0, 0, 1)
|
||||||
if s:EasyMotion_cancelled
|
if s:EasyMotion_cancelled
|
||||||
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
||||||
return ''
|
return ''
|
||||||
else
|
else
|
||||||
let pos1 = [line('.'), col('.')]
|
let pos1 = [line('.'), col('.')]
|
||||||
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
||||||
call s:EasyMotion('^\(\w\|\s*\zs\|$\)', 2, '', '', pos1[0], 1, 1)
|
call s:EasyMotion('^\(\w\|\s*\zs\|$\)', 2, '', 0, pos1[0], 1, 1)
|
||||||
if s:EasyMotion_cancelled
|
if s:EasyMotion_cancelled
|
||||||
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
||||||
return ''
|
return ''
|
||||||
@ -279,7 +294,7 @@ function! EasyMotion#SelectPhrase() "{{{
|
|||||||
let orig_pos = [line('.'), col('.')]
|
let orig_pos = [line('.'), col('.')]
|
||||||
|
|
||||||
" First
|
" First
|
||||||
call s:EasyMotion(re, 2, '', '', 0, 0, 0, 0)
|
call s:EasyMotion(re, 2, '', 0, 0, 0, 0, 0)
|
||||||
if s:EasyMotion_cancelled
|
if s:EasyMotion_cancelled
|
||||||
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
||||||
return ''
|
return ''
|
||||||
@ -290,7 +305,7 @@ function! EasyMotion#SelectPhrase() "{{{
|
|||||||
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
||||||
|
|
||||||
" Second
|
" Second
|
||||||
call s:EasyMotion(re, 2, '', '', 0, 0, 0, pos1)
|
call s:EasyMotion(re, 2, '', 0, 0, 0, 0, pos1)
|
||||||
if s:EasyMotion_cancelled
|
if s:EasyMotion_cancelled
|
||||||
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
||||||
return ''
|
return ''
|
||||||
@ -334,7 +349,7 @@ endfunction "}}}
|
|||||||
function! EasyMotion#User(pattern, mode, direction) " {{{
|
function! EasyMotion#User(pattern, mode, direction) " {{{
|
||||||
let visualmode = match('\v([Vv])|(C-v)', a:mode) > 0 ? visualmode() : ''
|
let visualmode = match('\v([Vv])|(C-v)', a:mode) > 0 ? visualmode() : ''
|
||||||
let re = escape(a:pattern, '|')
|
let re = escape(a:pattern, '|')
|
||||||
call s:EasyMotion(re, a:direction, visualmode, a:mode)
|
call s:EasyMotion(re, a:direction, visualmode, 0)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! EasyMotion#UserMapping(re, mapping, direction) " {{{
|
function! EasyMotion#UserMapping(re, mapping, direction) " {{{
|
||||||
silent exec "nnoremap ".a:mapping." :call EasyMotion#User('".a:re."', 0, ".a:direction.")<CR>"
|
silent exec "nnoremap ".a:mapping." :call EasyMotion#User('".a:re."', 0, ".a:direction.")<CR>"
|
||||||
@ -351,8 +366,9 @@ function! EasyMotion#Repeat(visualmode) " {{{
|
|||||||
let re = s:previous.regexp
|
let re = s:previous.regexp
|
||||||
let direction = s:previous.direction
|
let direction = s:previous.direction
|
||||||
let s:line_flag = s:previous.line_flag
|
let s:line_flag = s:previous.line_flag
|
||||||
|
let is_exclusive = mode(1) ==# 'no' ? 1 : 0
|
||||||
|
|
||||||
call s:EasyMotion(re, direction, a:visualmode ? visualmode() : '', mode(1))
|
call s:EasyMotion(re, direction, a:visualmode ? visualmode() : '', is_exclusive)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
@ -1022,7 +1038,7 @@ function! s:PromptUser(groups, allows_repeat, fixed_column) "{{{
|
|||||||
return s:PromptUser(target, a:allows_repeat, a:fixed_column)
|
return s:PromptUser(target, a:allows_repeat, a:fixed_column)
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
function! s:EasyMotion(regexp, direction, visualmode, mode, ...) " {{{
|
function! s:EasyMotion(regexp, direction, visualmode, is_exclusive, ...) " {{{
|
||||||
" For Special Function {{{
|
" For Special Function {{{
|
||||||
" For SelectLines(), to highlight previous selected line
|
" For SelectLines(), to highlight previous selected line
|
||||||
let hlcurrent = a:0 >= 1 ? a:1 : 0
|
let hlcurrent = a:0 >= 1 ? a:1 : 0
|
||||||
@ -1228,7 +1244,7 @@ function! s:EasyMotion(regexp, direction, visualmode, mode, ...) " {{{
|
|||||||
" -- Update cursor position -------------- {{{
|
" -- Update cursor position -------------- {{{
|
||||||
call cursor(orig_pos[0], orig_pos[1])
|
call cursor(orig_pos[0], orig_pos[1])
|
||||||
" Handle operator-pending mode {{{
|
" Handle operator-pending mode {{{
|
||||||
if a:mode == 'no'
|
if a:is_exclusive == 1
|
||||||
" This mode requires that we eat one more
|
" This mode requires that we eat one more
|
||||||
" character to the right if we're using
|
" character to the right if we're using
|
||||||
" a forward motion
|
" a forward motion
|
||||||
|
Loading…
x
Reference in New Issue
Block a user