Provide "REPL" on cqP

This commit is contained in:
Tim Pope 2012-12-29 13:36:02 -05:00
parent 23ecbe5649
commit 37ace16eac

View File

@ -563,6 +563,22 @@ function! s:inputeval() abort
endif endif
endfunction endfunction
function! s:inputevalloop() abort
while 1
let input = s:input('')
if input ==# ''
return ''
else
try
echo "\n".foreplay#eval(input)
catch /^Clojure:/
catch
return 'echoerr '.string(v:exception)
endtry
endif
endwhile
endfunction
function! s:recall() abort function! s:recall() abort
try try
cnoremap <expr> ) <SID>inputclose() cnoremap <expr> ) <SID>inputclose()
@ -602,6 +618,7 @@ nnoremap <silent> <Plug>ForeplayEdit :<C-U>set opfunc=<SID>editop<CR>g@
xnoremap <silent> <Plug>ForeplayEdit :<C-U>call <SID>editop(visualmode())<CR> xnoremap <silent> <Plug>ForeplayEdit :<C-U>call <SID>editop(visualmode())<CR>
nnoremap <Plug>ForeplayPrompt :exe <SID>inputeval()<CR> nnoremap <Plug>ForeplayPrompt :exe <SID>inputeval()<CR>
nnoremap <Plug>ForeplayLoop :exe <SID>inputevalloop()<CR>
noremap! <Plug>ForeplayRecall <C-R>=<SID>recall()<CR> noremap! <Plug>ForeplayRecall <C-R>=<SID>recall()<CR>
@ -618,6 +635,7 @@ function! s:setup_eval() abort
nmap <buffer> cqq <Plug>ForeplayEditab nmap <buffer> cqq <Plug>ForeplayEditab
nmap <buffer> cqp <Plug>ForeplayPrompt nmap <buffer> cqp <Plug>ForeplayPrompt
nmap <buffer> cqP <Plug>ForeplayLoop
exe 'nmap <buffer> cqc <Plug>ForeplayPrompt' . &cedit . 'i' exe 'nmap <buffer> cqc <Plug>ForeplayPrompt' . &cedit . 'i'
map! <buffer> <C-R>( <Plug>ForeplayRecall map! <buffer> <C-R>( <Plug>ForeplayRecall