 (defn alphanumeric [s]
   (re-find #"^[a-z0-9]+$" s))
 
-(defn handle-new-note-keydown [e app owner]
+(defn handle-new-note-keydown [e note owner comm]
   (let [code (event->key e)
         which (.-which e)
         key (.toLowerCase (js/String.fromCharCode which))]
   (if (or (alphanumeric key) (== code "space"))
   (do
-    (om/transact! app [:current :title]
+    (om/transact! note :title
       #(str % key)
       [:title nil])
   )

    (do (.focus element)
       (.setSelectionRange element length length))))

(defn list-view [app owner]
  (reify
    om/IInitState
    (init-state [_]
      {:delete (chan)})
    om/IDidMount
    (did-mount [this]
      (focus-on-input)
    )
    om/IDidUpdate
    (did-update [this prev-props prev-state]
      (focus-on-input)
    )
    om/IWillMount
    (will-mount [_]
      (let [delete (om/get-state owner :delete)]
        (go (loop []
              (let [note (<! delete)]
                (om/transact! app :entered
                  (fn [xs] (vec (remove #(= note %) xs))))
                (recur))))))
    om/IRenderState
    (render-state [this state]
      (dom/div nil
        (dom/h1 nil app-title)
        (apply dom/ul nil
          (om/build-all note-view (:entered app)
            {:init-state state}))
        (dom/ul nil
          (indent-element
            (dom/li nil (dom/input #js {:type "text" :ref "newNote"
              :placeholder "Enter note here..."
              :onKeyDown #(handle-new-note-keydown % app owner)
              :value (get-in app [:current :title])
            })) (get-in app [:current :tab])
          )
          ;(dom/button #js {:onClick #(add-note app owner)} "Add note")
        )))))

(defn guid []
  (.getNextUniqueId (.getInstance IdGenerator)))

(defn add-note [app owner]
  (let [new-note (-> (om/get-node owner "newNote")
                        .-value)]
    (when new-note
      (om/transact! app :entered #(conj % new-note)))))

(om/root
  (fn [app owner]
    (reify om/IRender
      (render [_]
        (dom/div nil
          (om/build list-view app)
          ))))
  app-state
  {:target (. js/document (getElementById "app"))})

   40 "down"
   46 "del"
   32 "space"
   27 "escape"
   186 ";"})
 
(defn event-modifiers
