Allow for some additional post-processing

This commit makes the s:repeat function public as repeat#run to allow
manual remapping for customization.
This commit is contained in:
Andrew Radev 2012-11-03 19:37:05 +02:00 committed by Tim Pope
parent 613eb1c812
commit f1d0fbbdf4

View File

@ -68,7 +68,7 @@ function! repeat#setreg(sequence,register)
let g:repeat_reg = [a:sequence, a:register] let g:repeat_reg = [a:sequence, a:register]
endfunction endfunction
function! s:repeat(count) function! repeat#run(count)
if g:repeat_tick == b:changedtick if g:repeat_tick == b:changedtick
let r = '' let r = ''
if g:repeat_reg[0] ==# g:repeat_sequence && !empty(g:repeat_reg[1]) if g:repeat_reg[0] ==# g:repeat_sequence && !empty(g:repeat_reg[1])
@ -84,10 +84,9 @@ function! s:repeat(count)
let c = g:repeat_count let c = g:repeat_count
let s = g:repeat_sequence let s = g:repeat_sequence
let cnt = c == -1 ? "" : (a:count ? a:count : (c ? c : '')) let cnt = c == -1 ? "" : (a:count ? a:count : (c ? c : ''))
call feedkeys(r . cnt, 'n') exe 'norm ' . r . cnt . s
call feedkeys(s)
else else
call feedkeys((a:count ? a:count : '') . '.', 'n') exe 'norm! '.(a:count ? a:count : '') . '.'
endif endif
endfunction endfunction
@ -99,7 +98,7 @@ function! s:wrap(command,count)
endif endif
endfunction endfunction
nnoremap <silent> . :<C-U>call <SID>repeat(v:count)<CR> nnoremap <silent> . :<C-U>call repeat#run(v:count)<CR>
nnoremap <silent> u :<C-U>call <SID>wrap('u',v:count)<CR> nnoremap <silent> u :<C-U>call <SID>wrap('u',v:count)<CR>
if maparg('U','n') ==# '' if maparg('U','n') ==# ''
nnoremap <silent> U :<C-U>call <SID>wrap('U',v:count)<CR> nnoremap <silent> U :<C-U>call <SID>wrap('U',v:count)<CR>