                       (recur diff-sum (rest rl)))))))
 
 (def formatting-keymap
-  {["M" "f"] :fmt-pprint})
-
-(defn exec-pprint-old [k widget]
-  (let [cmd (formatting-keymap k)]
-    (if cmd
-      (let [fs (with-out-str (clojure.pprint/pprint (read-string (.getSelectedText widget))))]
-        (if *debug* (println "replacement: " fs " at: " (.getSelectionStart widget)))
-        (if fs (.replaceRange widget fs (.getSelectionStart widget) (.getSelectionEnd widget)))))))
-
-(defn exec-pprint [k widget]
+  {["M" "p"] :fmt-pprint ["M" "f"] :fmt-plain})
+
+(defn exec-format [k widget]
   (let [cmd (formatting-keymap k)]
     (if cmd
       (let [sel (.getSelectedText widget)]
-        (if sel (.replaceRange widget (reformat-all-forms sel) (.getSelectionStart widget) (.getSelectionEnd widget)))))))
+        (when sel
+        (cond
+          (= cmd :fmt-pprint) 
+            (.replaceRange widget (reformat-all-forms sel) (.getSelectionStart widget) (.getSelectionEnd widget))
+          (= cmd :fmt-plain)
+            (.replaceRange widget (format-code sel) (.getSelectionStart widget) (.getSelectionEnd widget))))))))
 
 (defn exec-paredit [k w]
   (let [cmd (keymap k)]


(declare sexp-dup)

(defn reformat-all-forms [s] 
  (let [rvec (map (fn [[offs p]]
                    (let [len (v/length p)]

    (keyPressed [this e]
      (let [k (convert-key-event e)
            p (exec-paredit k w)]
        (if p (.consume e) (exec-format k w))))))

(defn input-method-event-handler [w]
  (reify java.awt.event.InputMethodListener
