   [title]
   (let [title (set-title title)
         [mode mode-name] (get-mode title)]
-    (.setOption @editor "mode" mode)
+    (swap! editor #(.setOption % "mode" mode))
     (aset (by-id "mode") "innerHTML" mode-name)))
 
 ;; file functions -------------------------------------------------------------

  (if false
    (do
      (new-file)
      (.setValue @editor ""))
    (let [x (+ 10 (.-screenX js/window))
          y (+ 10 (.-screenY js/window))]
      (.open js/window "main.html" "_blank" 

(defn cut-func []
  (do
    (.set clipboard (.getSelection @editor))
    (swap! editor #(.replaceSelection % ""))))

(defn paste-func []
  (.replaceSelection @editor (.get clipboard)))
