Happy path for lookup macros

This commit is contained in:
Tim Pope 2014-04-12 20:57:55 -04:00
parent f5ded81baf
commit feb8ebc976

View File

@ -1260,9 +1260,14 @@ function! fireplace#ns(...) abort
endfunction endfunction
function! s:Lookup(ns, macro, arg) abort function! s:Lookup(ns, macro, arg) abort
" doc is in clojure.core in older Clojure versions
try try
let response = s:eval("(clojure.core/require '".a:ns.") (clojure.core/eval (clojure.core/list (if (ns-resolve 'clojure.core '".a:macro.") 'clojure.core/".a:macro." '".a:ns.'/'.a:macro.") '".a:arg.'))', {'session': 0}) if has_key(fireplace#client(), 'connection') && fireplace#client().connection.describe.versions.clojure.minor > 2
call fireplace#client().preload(a:ns)
let response = s:eval('('.a:ns.'/'.a:macro.' '.a:arg.')', {'session': 0})
else
" doc is in clojure.core in older Clojure versions
let response = s:eval("(clojure.core/require '".a:ns.") (clojure.core/eval (clojure.core/list (if (ns-resolve 'clojure.core '".a:macro.") 'clojure.core/".a:macro." '".a:ns.'/'.a:macro.") '".a:arg.'))', {'session': 0})
endif
call s:output_response(response) call s:output_response(response)
catch /^Clojure:/ catch /^Clojure:/
catch /.*/ catch /.*/