 
 (wire-search text-chan app-state)
 
+(defn mk-delete-example [app-state]
+  (fn [ex-to-del]
+    (swap! app-state update-in [:examples]
+      (fn [exs]
+        (vec (remove #(= ex-to-del %) exs))))))
+
 (on-el-om
-  [:.examples-widget examples/$examples]
+  [:.examples-widget examples/$examples {:init-state {:delete-ex (mk-delete-example app-state)}}]
   [:.see-alsos-widget see-alsos/$see-alsos]
   [:.search-widget search/$quick-lookup {:init-state {:text-chan text-chan}}]
   [:.quick-search-widget search/$quick-search {:init-state {:text-chan text-chan}}]

    ;; ctrl-s to focus search input
    (when (and (.-ctrlKey e) (= 83 (.-keyCode e)))
      (doseq [$el (sel ".search input[name='query']")]
        (prn $el)
        (.focus $el)))))

(def tog (atom false))

  (fn [$el]
    (om/root
      examples/$examples
      {:examples [ex-example-0
                  ex-example-1
                  ex-example-2]}
      {:target $el}))

  :.sg-add-example
  (fn [$el]
    (om/root
      examples/$add
      {:editing? true}
      {:target $el}))

  :.sg-add-example-loading
  (fn [$el]
    (om/root
      examples/$add
      {:editing? true :loading? true :body "(defn greet [name]\n  (println \"Hello\" name))"}
      {:target $el}))

  :.sg-add-example-errors
  (fn [$el]
    (om/root
      examples/$add
      {:editing? true :body "(defn greet [name]\n  (println \"Hello\" name))"}
      {:target $el
       :init-state {:error-message "This is where error messages that apply to the whole form go. And here's some other text to show what happens with a very long error message."}}))

  :.sg-edit-example
  (fn [$el]
    (om/root
      examples/$example
      (merge
        ex-example-0
        {:editing? true
         :can-delete? true})
      {:target $el}))

  :.sg-delete-example
  (fn [$el]
    (om/root
      examples/$example-meta
      {:body "user=> (foo)"
       :author {:login "zk" :account-source "github" :avatar-url "https://avatars.githubusercontent.com/u/7194?v=2"}
       :history [{:author {:login "dakrone" :account-source "github" :avatar-url "https://avatars3.githubusercontent.com/u/19060?v=2&s=460"}}]
       :can-delete? true}
      {:target $el}))

  :.sg-delete-example-confirm
  (fn [$el]
    (om/root
      examples/$example-meta
      {:body "user=> (foo)"
       :author {:login "zk" :account-source "github" :avatar-url "https://avatars.githubusercontent.com/u/7194?v=2"}
       :history [{:author {:login "dakrone" :account-source "github" :avatar-url "https://avatars3.githubusercontent.com/u/19060?v=2&s=460"}}]
       :can-delete? true}
      {:target $el :init-state {:delete-state :confirm}}))

  :.sg-delete-example-loading
  (fn [$el]
    (om/root
      examples/$example-meta
      {:body "user=> (foo)"
       :author {:login "zk" :account-source "github" :avatar-url "https://avatars.githubusercontent.com/u/7194?v=2"}
       :history [{:author {:login "dakrone" :account-source "github" :avatar-url "https://avatars3.githubusercontent.com/u/19060?v=2&s=460"}}]
       :can-delete? true}
      {:target $el :init-state {:delete-state :loading}}))

  :.sg-delete-example-error
  (fn [$el]
    (om/root
      examples/$example-meta
      {:body "user=> (foo)"
       :author {:login "zk" :account-source "github" :avatar-url "https://avatars.githubusercontent.com/u/7194?v=2"}
       :history [{:author {:login "dakrone" :account-source "github" :avatar-url "https://avatars3.githubusercontent.com/u/19060?v=2&s=460"}}]
       :can-delete? true}
      {:target $el :init-state {:delete-state :error}}))

  :.sg-notes-null-state
  (fn [$el]
