                            :length (- (.getSelectionEnd widget)
                                       (.getSelectionStart widget))})))
 
-(defn insert-result
+(defn insert-result!
   [w pe]
   (dorun
     (map #(if (= 0 (:length %))

   ["M" "{"] :paredit-open-curly
   ["M" "}"] :paredit-close-curly})

(defn exec-paredit
  [k w buffer enable-default? enable-advanced?]
  (when-let [cmd (or (and enable-default?
                          (default-keymap k))
                     (and @enable-advanced?
                          (or (advanced-keymap k)
                              (foreign-keymap k))))]
    (let [result (exec-command cmd w buffer)]
      (insert-result w result))
    cmd))

(defn convert-input-method-event
  [event]
  ["M" (os-x-charmap (str (.first (.getText event))))])

(defn convert-key-event
  [event]

   [nil "{"] :paredit-open-curly
   [nil "}"] :paredit-close-curly
   [nil "\b"] :paredit-backward-delete
   [nil "DEL"] :paredit-forward-delete
   [nil "\""] :paredit-doublequote ;; \"
   ; ["C" "K"] :paredit-kill
   ["M" "("] :paredit-wrap-round
   ; ["M" ")"] :paredit-close-round-and-newline
