       (.setCursor cm (aget cursor "line") new-cursor-x))
     (.scrollTo cm scroll-x scroll-y)))
 
-#_(defn render-demo! []
-    (create-editor! "code-demo" :demo)
-    (editor-ui/render! :demo)
-    (start-editor-sync!)
-    (swap! editor-state assoc-in [:demo :text] demo-example))
-
-
 ;;----------------------------------------------------------------------
 ;; Life Cycle events
 ;;----------------------------------------------------------------------

         cm)))))

(defn cm-selection-or-form [cm]
  (let [selection (or (when (= (aget (selection cm) 0) "")
                        (-> @editor-state
                            :editor
                            :text))
                      (aget (selection cm) 0))]
    selection))

(defn create-editor!

       (.on cm "beforeChange" before-change)
       (.on cm "cursorActivity" on-cursor-activity)

       (.addKeyMap cm #js {"Ctrl-Enter" (fn [cm] (evaluate (cm-selection-or-form cm)))})

       cm))))

