                                (max (dec (editor/line-length ed (:line neue))) 0)
                                0))))))
 
-(defn move-loc [ed dir loc]
+(defn move-loc [ed dir loc & {:keys [line]}]
   (when loc
-    (let [len (editor/line-length ed (:line loc))
+    (let [len (if line
+                (count line)
+                (editor/line-length ed (:line loc)))
           neue (editor/adjust-loc loc (if (= dir :left) -1 1))]
       (cond
        (< (:ch neue) 0) (move-loc-line ed loc :up)
        (>= (:ch neue) len) (move-loc-line ed loc :down)
        :else neue))))
 
-(defn peek-ch [ed dir loc]
-  (when-let [next-loc (move-loc ed dir loc)]
-    (get-ch ed next-loc)))
 
 (defn within-range [[start end] cur]
   (>= end (:line cur) start))
+
 
 
 (defn loc-next-end-pair [ed loc]

;; Improved form selection utils
;; ==================================

(defn whitespace? [ch]
  (some #{\space \newline \tab} right-char))

(defn- end-pair? [ch]
  (some #{\) \} \]} ch))

              (not (within-range search-range cur)))
        nil
        (let [ch (get line (:ch cur))
              next-loc (move-loc ed :right cur :line line)
              next-line (if (not= (:line cur) (:line next-loc))
                          (editor/line ed (:line next-loc))
                          line)]
          (cond
           (not (or (start-pair? ch) (end-pair? ch))) (recur next-loc next-line level)
           (string|comment? ed cur) (recur next-loc next-line level)
           (start-pair? ch) (recur next-loc next-line (inc level))
           (and (end-pair? ch) (= 0 level)) cur
           (end-pair? ch) (recur next-loc next-line (dec level))
