Implement activate function

For clever motion & highlight
This commit is contained in:
haya14busa 2014-01-23 11:38:00 +09:00
parent fdfdfd06f1
commit 33bf1de0f8
3 changed files with 22 additions and 1 deletions

View File

@ -761,6 +761,15 @@ endfunction "}}}
function! EasyMotion#is_active() "{{{
return s:EasyMotion_is_active
endfunction "}}}
function! EasyMotion#activate(is_visual) "{{{
let s:EasyMotion_is_active = 1
call EasyMotion#attach_active_autocmd()
call EasyMotion#highlight#add_highlight(s:previous.regexp, 'EasyMotionMoveHL')
call EasyMotion#highlight#attach_autocmd()
if a:is_visual == 1
normal! gv
endif
endfunction "}}}
"}}}
" Grouping Algorithms: {{{
let s:grouping_algorithms = {

View File

@ -367,6 +367,9 @@ map <silent><expr><Plug>(easymotion-clever-s2)
map <silent><expr><Plug>(easymotion-clever-sn)
\ EasyMotion#is_active() ? '<Plug>(easymotion-next)' : '<Plug>(easymotion-sn)'
noremap <silent><Plug>(easymotion-activate) :<C-u>call EasyMotion#activate(0)<CR>
xnoremap <silent><Plug>(easymotion-activate) :<C-u>call EasyMotion#activate(1)<CR>
" }}}
" == Default key mapping {{{

View File

@ -1,7 +1,7 @@
"=============================================================================
" FILE: t/easymotion_spec.vim
" AUTHOR: haya14busa
" Last Change: 22 Jan 2014.
" Last Change: 23 Jan 2014.
" Test: https://github.com/kana/vim-vspec
" Refer: https://github.com/rhysd/clever-f.vim
" Description: EasyMotion test with vim-vspec
@ -393,6 +393,15 @@ describe 'Default settings'
Expect maparg('<Plug>(easymotion-special-pd)', 'n')
\ ==# ':<C-U>call EasyMotion#SelectPhraseDelete()<CR>'
" }}}
" Activate {{{
Expect maparg('<Plug>(easymotion-activate)', 'n')
\ ==# ':<C-U>call EasyMotion#activate(0)<CR>'
Expect maparg('<Plug>(easymotion-activate)', 'o')
\ ==# ':<C-U>call EasyMotion#activate(0)<CR>'
Expect maparg('<Plug>(easymotion-activate)', 'v')
\ ==# ':<C-U>call EasyMotion#activate(1)<CR>'
" }}}
end
it 'provide autoload functions'