       js/CodeMirror.Pass
       (f cm))))
 
-(defn editor [props value]
-  (let [history-next (make-history-next props)
-        history-prev (make-history-prev props)
-        submit       (make-submit props)
+(defn insert-pair [cm pair]
+  (debugf "I!")
+  (doto cm
+    (.replaceSelection "()")
+    (.execCommand "goCharLeft")))
+
+(defn editor [props text]
+  (let [on-change    (wrap-on-change props)
+        history-next (wrap-history-next props)
+        history-prev (wrap-history-prev props)
+        on-submit    (wrap-on-submit props)
         extra-keys   {:Up         (-> history-prev wrap-ignore-multi)
                       :Down       (-> history-next wrap-ignore-multi)
                       :Ctrl-Up    history-prev
                       :Ctrl-Down  history-next
-                      :Enter      (-> submit wrap-ignore-multi)
-                      :Ctrl-Enter submit}]
+                      :Enter      (-> on-submit wrap-ignore-multi)
+                      :Ctrl-Enter on-submit
+                      :Shift-9    #(insert-pair % "()")
+                      "["         #(insert-pair % "[]")
+                      "Shift-{"   #(insert-pair % "{}")
+                      "Shift-'"   #(insert-pair % "\"\"")}]
     (fn []
-      [codemirror
-       {:editable?  true
-        :numbers?   false
-        :focus?     true
-        :extra-keys extra-keys}
-       value])))
+      [codemirror (-> {:editable?  true
+                       :numbers?   false
+                       :focus?     true
+                       :extra-keys extra-keys
+                       :on-change  on-change}
+                      (merge (dissoc props :on-change)))
+       text])))
 
 (defn code [text]
   [codemirror {:read-only? true :mode "clojure"} text])

    true)
  (reset! editor nil))

(defn cm-render [_ text]
  [:textarea {:value text :read-only true}])

(defn codemirror [props text]

        editor  (reset! editor (js/CodeMirror.fromTextArea element cm-opts))]
    (.setValue editor text)
    (when on-change
      (.on editor "change" on-change))))

(defn cm-will-update [node editor [_ _ text]]
  (debugf "Update")
