Refactor map! macro
This commit is contained in:
parent
a55b3c599b
commit
71061aefa1
1 changed files with 10 additions and 12 deletions
|
@ -179,7 +179,6 @@ Examples:
|
||||||
|
|
||||||
(defmacro map! (&rest rest)
|
(defmacro map! (&rest rest)
|
||||||
(let ((i 0)
|
(let ((i 0)
|
||||||
(forms '())
|
|
||||||
(keymaps (if (boundp 'keymaps) keymaps))
|
(keymaps (if (boundp 'keymaps) keymaps))
|
||||||
(default-keymaps '((current-global-map)))
|
(default-keymaps '((current-global-map)))
|
||||||
(state-map '(("n" . normal)
|
(state-map '(("n" . normal)
|
||||||
|
@ -190,13 +189,12 @@ Examples:
|
||||||
("m" . motion)
|
("m" . motion)
|
||||||
("r" . replace)))
|
("r" . replace)))
|
||||||
(prefix (if (boundp 'prefix) prefix))
|
(prefix (if (boundp 'prefix) prefix))
|
||||||
key def states)
|
key def states forms)
|
||||||
(unless keymaps
|
(unless keymaps
|
||||||
(setq keymaps default-keymaps))
|
(setq keymaps default-keymaps))
|
||||||
(while rest
|
(while rest
|
||||||
(setq key (pop rest))
|
(setq key (pop rest))
|
||||||
(add-to-list
|
(push
|
||||||
'forms
|
|
||||||
(cond ((listp key) ; it's a sub exp
|
(cond ((listp key) ; it's a sub exp
|
||||||
`(,(macroexpand `(map! ,@key))))
|
`(,(macroexpand `(map! ,@key))))
|
||||||
|
|
||||||
|
@ -246,9 +244,9 @@ Examples:
|
||||||
out-forms))
|
out-forms))
|
||||||
|
|
||||||
(t (user-error "Invalid key %s" key)))
|
(t (user-error "Invalid key %s" key)))
|
||||||
t)
|
forms)
|
||||||
(cl-incf i))
|
(cl-incf i))
|
||||||
`(progn ,@(apply #'nconc (delete nil (delete (list nil) forms)))))))
|
`(progn ,@(apply #'nconc (delete nil (delete (list nil) (reverse forms))))))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue