   [state key-]
   (update state key- conj (get-cached-state state)))
 
+(defn process-indent-trigger
+  "Called when we have actually reached an indentation trigger.
+  (i.e. first non-whitespace char of a line)"
+  [{:keys [x-pos] :as state}]
+  (-> state
+      (close-delims x-pos)
+      (commit-cached-state :postindent-states)
+      (assoc :track-indent? false
+             :processed-indent? true)))
+
 (defn process-indent
   "Update the state by handling a possible indentation trigger.
 

  (let [x-pos (count (get lines line-no))
        state (assoc state :x-pos x-pos :ch (str ch))
        state (process-indent state)]
    (cond-> state
      (:process? state) process-char*)))

(defn process-line
  "Update the state by processing the given line of text."
  ([line] (process-line initial-state line))
  ([{:keys [stack lines line-no cursor-line] :as state} line]
   (let [line-no (inc line-no)
         state (assoc state
                  :backup []
                  :cursor-in-comment? false

                  :line-no line-no
                  :removed-delims [])
         state (update-in state [:insert :line-dy] #(when % (dec %)))

         state (reduce process-char state (str line "\n"))]
     (if (:quit? state)
       (reduced state)
       (postprocess-line state)))))

(defn finalize-state
  [{:keys [stack quote-danger?] :as state}]
