Provide and use foreplay#evalprint()
This provides a central point for alternate output methods, such as capturing to a buffer. In support of #7.
This commit is contained in:
parent
e62540fef9
commit
fbc0c54548
@ -408,6 +408,14 @@ function! foreplay#eval(expr) abort
|
|||||||
throw err
|
throw err
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! foreplay#evalprint(expr) abort
|
||||||
|
try
|
||||||
|
echo foreplay#eval(a:expr)
|
||||||
|
catch /^Clojure:/
|
||||||
|
endtry
|
||||||
|
return ''
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! foreplay#evalparse(expr) abort
|
function! foreplay#evalparse(expr) abort
|
||||||
let response = s:eval(
|
let response = s:eval(
|
||||||
\ '(symbol ((fn *vimify [x]' .
|
\ '(symbol ((fn *vimify [x]' .
|
||||||
@ -485,23 +493,16 @@ function! s:printop(type) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:print_last() abort
|
function! s:print_last() abort
|
||||||
try
|
call foreplay#evalprint(s:todo)
|
||||||
echo foreplay#eval(s:todo)
|
|
||||||
catch /^Clojure:/
|
|
||||||
endtry
|
|
||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:editop(type) abort
|
function! s:editop(type) abort
|
||||||
call feedkeys(&cedit . "\<Home>", 'n')
|
call feedkeys(&cedit . "\<Home>", 'n')
|
||||||
let input = s:input(substitute(substitute(s:opfunc(a:type), "\s*;[^\n]*", '', 'g'), '\n\+\s*', ' ', 'g'))
|
let input = s:input(substitute(substitute(s:opfunc(a:type), "\s*;[^\n]*", '', 'g'), '\n\+\s*', ' ', 'g'))
|
||||||
try
|
|
||||||
if input !=# ''
|
if input !=# ''
|
||||||
echo foreplay#eval(input)
|
call foreplay#evalprint(input)
|
||||||
endif
|
endif
|
||||||
catch /^Clojure:/
|
|
||||||
return ''
|
|
||||||
endtry
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:Eval(bang, line1, line2, count, args) abort
|
function! s:Eval(bang, line1, line2, count, args) abort
|
||||||
@ -524,9 +525,9 @@ function! s:Eval(bang, line1, line2, count, args) abort
|
|||||||
exe line1.','.line2.'delete _'
|
exe line1.','.line2.'delete _'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
if a:bang
|
||||||
try
|
try
|
||||||
let result = foreplay#eval(expr)
|
let result = foreplay#eval(expr)
|
||||||
if a:bang
|
|
||||||
if a:args !=# ''
|
if a:args !=# ''
|
||||||
call append(a:line1, result)
|
call append(a:line1, result)
|
||||||
exe a:line1
|
exe a:line1
|
||||||
@ -534,11 +535,11 @@ function! s:Eval(bang, line1, line2, count, args) abort
|
|||||||
call append(a:line1-1, result)
|
call append(a:line1-1, result)
|
||||||
exe a:line1-1
|
exe a:line1-1
|
||||||
endif
|
endif
|
||||||
else
|
|
||||||
echo result
|
|
||||||
endif
|
|
||||||
catch /^Clojure:/
|
catch /^Clojure:/
|
||||||
endtry
|
endtry
|
||||||
|
else
|
||||||
|
call foreplay#evalprint(expr)
|
||||||
|
endif
|
||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -584,14 +585,7 @@ function! s:inputeval() abort
|
|||||||
if input ==# ''
|
if input ==# ''
|
||||||
return ''
|
return ''
|
||||||
else
|
else
|
||||||
try
|
call foreplay#evalprint(input)
|
||||||
echo foreplay#eval(input)
|
|
||||||
return ''
|
|
||||||
catch /^Clojure:/
|
|
||||||
return ''
|
|
||||||
catch
|
|
||||||
return 'echoerr '.string(v:exception)
|
|
||||||
endtry
|
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user