Support booleans in foreplay#evalparse

This commit is contained in:
Tim Pope 2013-02-08 10:26:14 -05:00
parent a6012b5032
commit a1068949b1

View File

@ -526,17 +526,20 @@ function! foreplay#evalprint(expr) abort
return foreplay#eval_prn(a:expr) return foreplay#eval_prn(a:expr)
endfunction endfunction
function! foreplay#evalparse(expr, ...) abort let g:foreplay#reader =
let options = extend({'session': 0}, a:0 ? a:1 : {})
let response = s:eval(
\ '(symbol ((fn *vimify [x]' . \ '(symbol ((fn *vimify [x]' .
\ ' (cond' . \ ' (cond' .
\ ' (map? x) (str "{" (apply str (interpose ", " (map (fn [[k v]] (str (*vimify k) ": " (*vimify v))) x))) "}")' . \ ' (map? x) (str "{" (apply str (interpose ", " (map (fn [[k v]] (str (*vimify k) ": " (*vimify v))) x))) "}")' .
\ ' (coll? x) (str "[" (apply str (interpose ", " (map *vimify x))) "]")' . \ ' (coll? x) (str "[" (apply str (interpose ", " (map *vimify x))) "]")' .
\ ' (true? x) "1"' .
\ ' (false? x) "0"' .
\ ' (number? x) (pr-str x)' . \ ' (number? x) (pr-str x)' .
\ ' (keyword? x) (pr-str (name x))' . \ ' (keyword? x) (pr-str (name x))' .
\ ' :else (pr-str (str x)))) '.a:expr.'))', \ ' :else (pr-str (str x)))) %s))'
\ options)
function! foreplay#evalparse(expr, ...) abort
let options = extend({'session': 0}, a:0 ? a:1 : {})
let response = s:eval(printf(g:foreplay#reader, a:expr), options)
call s:output_response(response) call s:output_response(response)
if get(response, 'ex', '') !=# '' if get(response, 'ex', '') !=# ''