Created
December 11, 2008 04:14
-
-
Save Chouser/34602 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn bind-vec [state-map start-state [stroke & strokes] func force?] | |
(when-not force? | |
(let [old-val (get-in start-state [start-state stroke])] | |
(cond | |
(and (symbol? old-val) (not strokes)) | |
(throw (Exception. "New binding would be eclipsed by existing binding")) | |
(and (not (symbol? old-var)) strokes) | |
(throw (Exception. "Existing binding would eclipse new binding")) | |
(and (not (symbol? old-var)) (not strokes)) | |
(throw (Exception. "New binding would replace existing binding"))))) | |
(if strokes | |
(let [new-state (gensym 'state)] | |
(recur (assoc-in state-map [start-state stroke] new-state) | |
new-state strokes func force?)) | |
(assoc-in state-map [start-state stroke] func))) | |
; ...and then something like: | |
(defn register [] (alt nil [\" (append :register (alpha))])) | |
(defn num-arg [arg-name] (alt nil [(append arg-name (digit)) (num-arg arg-name)])) | |
(bind-keys :cmd [(num-arg :early-num) (register) \y | |
(alt (append :double \y) (movement) (visual-block))]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment