   (deref [_] @cursor))
 
 (defmethod print-method Buffer [buffer writer]
-  (print-simple (format "#<Buffer %s -> %s>" (:name buffer) (pr-str @ buffer)) writer))
-
-(defn buffer [name ^Cursor cursor updatefn keymapfn]
-  (Buffer. name cursor updatefn keymapfn nil nil))
-
-(defn buffer? [x]
-  (instance? Buffer x))
+  (print-simple (format "#<Buffer %s -> %s>" (:name buffer) (pr-str (:cursor buffer))) writer))
 
 (defn sender [^Agent buffers name]
   (fn [state]
     (send buffers assoc name state)))
 
+(defn buffer [name updatefn & {:keys [cursor keymapfn mode file]
+                               :or {cursor (cursor/cursor "" 0) keymapfn fundamental-mode-keymap}}]
+  (Buffer. name cursor updatefn keymapfn mode file))
+
+
+(defn buffer? [x]
+  (instance? Buffer x))
+
+(defn create-buffer [^Agent buffers name & args]
+  (send buffers assoc name (apply buffer name (sender buffers name) args))
+  (@buffers name))
+
 (defn loader [^Agent buffers]
   (fn [[name] _]
+    (when-not (@buffers name)
+      (create-buffer buffers name))
     (let [cursor (get-in @buffers [name :cursor]),
           rope @cursor,
           [row column] (rope/translate rope (cursor/pos cursor))]

(ns engine.data.buffer
  (:use engine.data.mode)
  (:require [engine.data.rope :as rope]
            [engine.data.cursor :as cursor]
            [clojure.tools.logging :as log])

                          [@state (cursor/pos state)])),
          [row column] (apply rope/translate state)]
      {:response (conj (or (transfn pre-state state name) [])
                       (command "move-to-position" {:row row :column column}))}))
  (trans [this actionfn] (trans this actionfn (fn [& _] nil)))

  (inputfn [this]
