Meikel  Brandmeyer avatar Meikel Brandmeyer committed 276f588

Improve error reporting on repl start (reported by M. Swanson)

Comments (0)

Files changed (2)


-    [vimclojure.util :only [safe-var-get stream->seq
+    [vimclojure.util :only [resolve-and-load-namespace safe-var-get stream->seq
                             pretty-print pretty-print-causetrace]])
 (defn make-repl
   "Create a new Repl."
-  ([id] (make-repl id (the-ns 'user)))
+  ([id] (make-repl id nil))
   ([id namespace]
    {:id        id
-    :ns        namespace
+    :ns        (or namespace (resolve-and-load-namespace 'user))
     :test-out  nil
     :line      1
     :bindings  (-> (reduce add-binding {} bindable-vars)
 (defn start
   "Start a new Repl and register it in the system."
-  ; Make sure user namespace exists.
   (let [id       (repl-id)
         the-repl (make-repl id nspace)]
     (swap! *repls* assoc id the-repl)


 " The Repl
 let vimclojure#Repl = copy(vimclojure#Buffer)
+let vimclojure#Repl.__superBufferNew = vimclojure#Repl.New
 let vimclojure#Repl.__superBufferInit = vimclojure#Repl.Init
 let vimclojure#Repl._history = []
 	call g:vimclojure#Repl.New(ns)
+" FIXME: Ugly hack. But easier than cleaning up the buffer
+" mess in case something goes wrong with repl start.
+function! vimclojure#Repl.New(namespace) dict
+	let replStart = vimclojure#ExecuteNail("Repl", "-s",
+				\ "-n", a:namespace)
+	if replStart.stderr != ""
+		call vimclojure#ReportError(replStart.stderr)
+		return
+	endif
+	let instance = call(self.__superBufferNew, [a:namespace], self)
+	let instance._id =
+	call vimclojure#ExecuteNailWithInput("Repl",
+				\ "(require 'clojure.stacktrace)",
+				\ "-r", "-i", instance._id)
+	return instance
 function! vimclojure#Repl.Init(namespace) dict
 	call self.__superBufferInit()
 	call append(line("$"), ["Clojure", self._prompt . " "])
-	let replStart = vimclojure#ExecuteNail("Repl", "-s",
-				\ "-n", a:namespace)
-	let self._id =
-	call vimclojure#ExecuteNailWithInput("Repl",
-				\ "(require 'clojure.stacktrace)",
-				\ "-r", "-i", self._id)
 	let b:vimclojure_repl = self
 	set filetype=clojure
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.