Use namespaces in critical path

This commit is contained in:
Tim Pope 2013-01-16 01:01:09 -05:00
parent aed21575b8
commit f4e9f1c10a
2 changed files with 11 additions and 8 deletions

View File

@ -146,7 +146,10 @@ endfunction
function! s:nrepl_eval(expr, ...) dict abort
let payload = {"op": "eval"}
let payload.code = '(try (eval ''(do '.a:expr."\n".')) (catch Exception e (print (apply str (interleave (repeat "\b") (map str (.getStackTrace e))))) (throw e)))'
let payload.code = '(try (clojure.core/eval ''(do '.a:expr."\n".'))' .
\ ' (catch Exception e' .
\ ' (clojure.core/print (clojure.core/apply clojure.core/str (clojure.core/interleave (clojure.core/repeat "\b") (clojure.core/map clojure.core/str (.getStackTrace e)))))' .
\ ' (throw e)))'
let options = a:0 ? a:1 : {}
if has_key(options, 'ns')
let payload.ns = options.ns

View File

@ -283,14 +283,14 @@ function! s:oneoff.eval(expr, options) dict abort
let java_cmd = exists('$JAVA_CMD') ? $JAVA_CMD : 'java'
let command = java_cmd.' -cp '.shellescape(self.classpath).' clojure.main -e ' .
\ shellescape(
\ '(binding [*out* (java.io.FileWriter. '.s:str(s:oneoff_out).')' .
\ ' *err* (java.io.FileWriter. '.s:str(s:oneoff_err).')]' .
\ '(clojure.core/binding [*out* (java.io.FileWriter. '.s:str(s:oneoff_out).')' .
\ ' *err* (java.io.FileWriter. '.s:str(s:oneoff_err).')]' .
\ ' (try' .
\ ' (require ''clojure.repl) '.ns.'(spit '.s:str(s:oneoff_pr).' (pr-str (eval (read-string (slurp '.s:str(s:oneoff_in).')))))' .
\ ' (clojure.core/require ''clojure.repl) '.ns.'(clojure.core/spit '.s:str(s:oneoff_pr).' (clojure.core/pr-str (clojure.core/eval (clojure.core/read-string (clojure.core/slurp '.s:str(s:oneoff_in).')))))' .
\ ' (catch Exception e' .
\ ' (spit *err* (.toString e))' .
\ ' (spit '.s:str(s:oneoff_ex).' (class e))' .
\ ' (spit '.s:str(s:oneoff_stk).' (apply str (interpose "\n" (.getStackTrace e))))))' .
\ ' (clojure.core/spit *err* (.toString e))' .
\ ' (clojure.core/spit '.s:str(s:oneoff_ex).' (clojure.core/class e))' .
\ ' (clojure.core/spit '.s:str(s:oneoff_stk).' (clojure.core/apply clojure.core/str (clojure.core/interpose "\n" (.getStackTrace e))))))' .
\ ' nil)')
let wtf = system(command)
let result = {}
@ -886,7 +886,7 @@ endfunction
function! s:Lookup(ns, macro, arg) abort
" doc is in clojure.core in older Clojure versions
try
call foreplay#eval("(require '".a:ns.") (eval (list (if (ns-resolve 'clojure.core '".a:macro.") 'clojure.core/".a:macro." '".a:ns.'/'.a:macro.") '".a:arg.'))')
call foreplay#eval("(require '".a:ns.") (clojure.core/eval (list (if (ns-resolve 'clojure.core '".a:macro.") 'clojure.core/".a:macro." '".a:ns.'/'.a:macro.") '".a:arg.'))')
catch /^Clojure:/
catch /.*/
echohl ErrorMSG