                          (throw (str "no matching open delimiter for " ch))))
     :else stack))
 
-(defmethod push-char* ";"
-  [stack [x-pos ch]]
-  (cond
-    (in-escape? stack) (pop stack)
+(defmethod push-char ";"
+  [stack [x-pos ch]]
+  (cond
+    (escaping? stack) (pop stack)
     (in-code? stack) (conj stack [x-pos ch])
     :else stack))
 
-(defmethod push-char* "\n"
-  [stack [x-pos ch]]
-  (let [s0 (cond-> stack (in-escape? stack) pop)
+(defmethod push-char "\n"
+  [stack [x-pos ch]]
+  (let [s0 (cond-> stack (escaping? stack) pop)
         s1 (cond-> s0 (in-comment? s0) pop)]
     s1))
 
-(defmethod push-char* "\\"
-  [stack [x-pos ch]]
-  (cond
-    (in-escape? stack) (pop stack)
+(defmethod push-char "\\"
+  [stack [x-pos ch]]
+  (cond
+    (escaping? stack) (pop stack)
     :else (conj stack [x-pos ch])))
 
-(defmethod push-char* "\""
-  [stack [x-pos ch]]
-  (cond
-    (in-escape? stack) (pop stack)
+(defmethod push-char "\""
+  [stack [x-pos ch]]
+  (cond
+    (escaping? stack) (pop stack)
     (in-str? stack) (pop stack)
     :else (conj stack [x-pos ch])))
 
-(defmethod push-char* :default
-  [stack [x-pos ch]]
-  (cond
-    (in-escape? stack) (pop stack)
-    :else stack))
+(defmethod push-char :default
+  [stack [x-pos ch]]
+  (cond
+    (escaping? stack) (pop stack)
+    :else stack))
+
+;;------------------------------------------------------------------------
+;; Closing Delimiter inferencing
+;;------------------------------------------------------------------------
+
+;; Utilities
 
 (defn whitespace? [ch]
   (re-find #"[\s,]" ch))

       insert
       (subs orig idx)))

(defn close-delims
  ([result] (close-delims result 0))
  ([result indent-x]
   (let [[stack delims] (loop [stack (:stack result), delims ""]
                          (if-not (seq stack)
                            [stack delims]
                            (let [[x ch] (peek stack)]
                              (if (>= x indent-x)
                                (recur (pop stack) (str delims (matching-delim ch)))
                                [stack delims]))))
         {:keys [line-no x-pos]} (:insert result)
         result (-> result
                    (update-in [:lines line-no] insert-string x-pos delims)


(defonce app-state (atom {:text ""}))

;;------------------------------------------------------------------------
;; Simple clojure delimiter parsing
;;
;; It handles:
;;  - multi-line strings
;;  - comments
;;  - escaped characters
;;------------------------------------------------------------------------

(def matching-delim
