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)
|
||||
(let ((i 0)
|
||||
(forms '())
|
||||
(keymaps (if (boundp 'keymaps) keymaps))
|
||||
(default-keymaps '((current-global-map)))
|
||||
(state-map '(("n" . normal)
|
||||
|
@ -190,13 +189,12 @@ Examples:
|
|||
("m" . motion)
|
||||
("r" . replace)))
|
||||
(prefix (if (boundp 'prefix) prefix))
|
||||
key def states)
|
||||
key def states forms)
|
||||
(unless keymaps
|
||||
(setq keymaps default-keymaps))
|
||||
(while rest
|
||||
(setq key (pop rest))
|
||||
(add-to-list
|
||||
'forms
|
||||
(push
|
||||
(cond ((listp key) ; it's a sub exp
|
||||
`(,(macroexpand `(map! ,@key))))
|
||||
|
||||
|
@ -246,9 +244,9 @@ Examples:
|
|||
out-forms))
|
||||
|
||||
(t (user-error "Invalid key %s" key)))
|
||||
t)
|
||||
forms)
|
||||
(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