                         (in-code? stack)
                         (not (whitespace? ch))
                         (not= ";" ch))
-        skip? (and check-indent? (closing-delim? ch))
-        at-indent? (and check-indent? (not skip?))
-        quit? (and at-indent? quote-danger?)
-        state (assoc state :process? (not skip?))]
-    (if at-indent?
-      (-> state
-          (close-delims x-pos)
-          (commit-cached-state :postindent-states)
-          (assoc :track-indent? false
-                 :processed-indent? true))
-      state)))
+        skip?       (and check-indent? (closing-delim? ch))
+        at-indent?  (and check-indent? (not skip?))
+        quit?       (and at-indent? quote-danger?)
+        state (assoc state
+                     :quit? quit?
+                     :process? (and (not skip?) (not quit?)))]
+    (cond-> state
+      (and at-indent? (not quit?)) process-indent-trigger)))
 
 (defn update-line
   "Update the state by adding processed character to the line."

                  :line-no line-no
                  :removed-delims [])
         state (update-in state [:insert :line-dy] #(when % (dec %)))
         state (reduce process-char state (str line "\n"))
         state (-> state
                   block-delim-trail
                   remove-delim-trail
                   save-preinsert-line
                   (commit-cached-state :postline-states))

         ;; if this did not have an indentation trigger point,
         ;; pad postindent-states with a nil.
         state (cond-> state
                 (not (:processed-indent? state))
                 (update :postindent-states conj nil))]
     state)))

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

  [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.

