Skip to content
Browse files

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

  • Loading branch information...
1 parent 692c476 commit c8f87a165ae2b90ce3f2b9ef0db7a2bc85c7b244 @kotarak committed Jun 20, 2011
Showing with 23 additions and 11 deletions.
  1. +3 −4 server/src/main/clojure/vimclojure/repl.clj
  2. +20 −7 vim/autoload/vimclojure.vim
View
7 server/src/main/clojure/vimclojure/repl.clj
@@ -24,7 +24,7 @@
(:require
clojure.test)
(:use
- [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]])
(:import
clojure.lang.Var
@@ -65,10 +65,10 @@
(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)
@@ -79,7 +79,6 @@
(defn start
"Start a new Repl and register it in the system."
[nspace]
- ; Make sure user namespace exists.
(let [id (repl-id)
the-repl (make-repl id nspace)]
(swap! *repls* assoc id the-repl)
View
27 vim/autoload/vimclojure.vim
@@ -687,6 +687,7 @@ endfunction
" 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 = []
@@ -699,6 +700,25 @@ function! vimclojure#StartRepl(...)
call g:vimclojure#Repl.New(ns)
endfunction
+" 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 = replStart.value.id
+ call vimclojure#ExecuteNailWithInput("Repl",
+ \ "(require 'clojure.stacktrace)",
+ \ "-r", "-i", instance._id)
+
+ return instance
+endfunction
+
function! vimclojure#Repl.Init(namespace) dict
call self.__superBufferInit()
@@ -709,13 +729,6 @@ function! vimclojure#Repl.Init(namespace) dict
call append(line("$"), ["Clojure", self._prompt . " "])
- let replStart = vimclojure#ExecuteNail("Repl", "-s",
- \ "-n", a:namespace)
- let self._id = replStart.value.id
- call vimclojure#ExecuteNailWithInput("Repl",
- \ "(require 'clojure.stacktrace)",
- \ "-r", "-i", self._id)
-
let b:vimclojure_repl = self
set filetype=clojure

0 comments on commit c8f87a1

Please sign in to comment.
Something went wrong with that request. Please try again.