Move define-key! macro to core-lib

This commit is contained in:
Henrik Lissner 2018-06-03 23:52:21 +02:00
parent 818cb27724
commit 796af69c28
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 28 additions and 21 deletions

View file

@ -153,27 +153,6 @@ For example, :nvi will map to (list 'normal 'visual 'insert). See
(defvar doom--defer nil)
(defvar doom--local nil)
(defmacro define-key! (keymaps key def &rest rest)
"TODO"
(declare (indent defun))
(if (and (listp keymaps)
(not (eq (car-safe keymaps) 'quote)))
`(dolist (map (list ,@keymaps))
,(macroexpand `(define-key! map ,key ,def ,@rest)))
(when (eq (car-safe keymaps) 'quote)
(pcase (cadr keymaps)
(`global (setq keymaps '(current-global-map)))
(`local (setq keymaps '(current-local-map)))
(x (error "%s is not a valid keymap" x))))
`(let ((map ,keymaps))
(define-key map ,key ,def)
,@(let (forms)
(while rest
(let ((key (pop rest))
(def (pop rest)))
(push `(define-key map ,key ,def) forms)))
(nreverse forms)))))
(defmacro map! (&rest rest)
"A nightmare of a key-binding macro that will use `evil-define-key*',
`define-key', `local-set-key' and `global-set-key' depending on context and