       :else
       (println error))))
 
+;; --------------------
+;; REPL specials
+
 (defn- compiler-state-backup []
   {:st     @st
    :loaded @cljs/*loaded*})

          0))
      0)))

(defn- current-alias-map []
  (let [cur-ns @current-ns]
    (into {} (remove (fn [[k v]] (= k v)))
      (merge (get-in @st [::ana/namespaces cur-ns :requires])
        (get-in @st [::ana/namespaces cur-ns :require-macros])))))

(defn- reader-eof? [msg]
  (or
    (= "EOF while reading" msg)
    (= "EOF while reading string" msg)))

(defn- read-chars
  [reader]
  (let [sb (StringBuffer.)]
    (loop [c (rt/read-char reader)]
      (if-not (nil? c)
        (do
          (.append sb c)
          (recur (rt/read-char reader)))
        (str sb)))))

(defn- repl-read-string
  "Returns a vector of the first read form, and any balance text."
  [source]
  (let [reader (rt/string-push-back-reader source)
        cur-ns @current-ns]
    (binding [ana/*cljs-ns* cur-ns
              *ns* (create-ns cur-ns)
              env/*compiler* st
              r/*data-readers* tags/*cljs-data-readers*
              r/resolve-symbol ana/resolve-symbol
              r/*alias-map* (current-alias-map)]
      [(r/read {:read-cond :allow :features #{:cljs}} reader) (read-chars reader)])))

(defn- is-completely-readable?
  [source]

  (load-core-analysis-caches repl?)
  (deps/index-upstream-foreign-libs))

;; --------------------
;; Autocompletion

(defn- drop-macros-suffix
