     "foo (bar baz)" 4 4 4 9
     "foo (bar baz)" 9 4 4 9 
     "foo (bar baz)" 0 0 0 0
+    "(foo bar)" 8 0 8 0
+    "foo (bar baz)" 12 1 4 9 
     ))
 
 (defn sel-match-normalized? 

                 "foo (bar| baz)" "foo (bar| |baz)"
                 "foo (bar |baz)" "foo (bar |baz|)"
                 "foo b|ar| baz" "foo |bar| baz"
                 "foo (bar baz|)" "foo |(bar baz)|";
                 "foo (bar |baz|)" "foo |(bar baz)|";
                 "foo \"bar |baz\"" "foo |\"bar baz\"|"
                 "foo;ba|r\nbaz" "foo|;bar\n|baz"
                 "foo (bar [ba|z] |foo)" "foo (bar |[baz] |foo)";;
                 "foo (bar [ba|z]) (foo [bar (b|az)])" "foo |(bar [baz]) (foo [bar (baz)])|"
                 "foo |(bar [baz (b|am)])" "foo |(bar [baz (bam)])|"
                 }]

  [cmd {:keys [#^String text offset length] :as t}]
  (let [parsed (parse text)]
    (if-let [rloc (-?> parsed (parsed-root-loc true))]
      (let [[l r] (normalized-selection rloc offset length)]
        (if-not (sel-match-normalized? offset length [l r])
          (-> t (assoc-in [:offset] (start-offset l))
            (assoc-in [:length] (if (nil? r) 0 (- (end-offset r) (start-offset l)))))
          (let [r (if (nil? r) 
                    l 
                    (if-let [nr (zip/right r)] 
                      nr
                      (zip/up r)))
                [l r] (normalized-selection rloc (spy (start-offset l)) (spy (- (end-offset r) (start-offset l))))]
            (-> t (assoc-in [:offset] (start-offset l))
              (assoc-in [:length] (if (nil? r) 0 (- (end-offset r) (start-offset l)))))))))))

(defmethod paredit
  :paredit-expand-up
  [cmd {:keys [#^String text offset length] :as t}]
  (let [parsed (parse text)]
    (if-let [rloc (-?> parsed (parsed-root-loc true))]
      (let [[l r] (normalized-selection rloc offset length)]
        (if-not (sel-match-normalized? offset length [l r])
          (-> t (assoc-in [:offset] (start-offset l))
            (assoc-in [:length] (if (nil? r) 0 (- (end-offset r) (start-offset l)))))
          (let [;
                _ (spy "l before up" (zip/node l))
                l (if-let [nl (zip/up (if (= offset (start-offset (parse-node l)))
                                        (parse-node l) 
                                        (parse-leave l)))]
                    nl 
                    l)
                _ (spy "l after up" (zip/node l))]
            (-> t (assoc-in [:offset] (start-offset l))
              (assoc-in [:length] (- (end-offset l) (start-offset l))))))))))

#_(defmethod paredit
  :paredit-expand-up
  [cmd {:keys [#^String text offset length] :as t}]
  (let [parsed (parse text)]
