:map no longer accepts lists; only eval-after-load if necessary

Fixes https://github.com/jwiegley/use-package/issues/324
This commit is contained in:
John Wiegley 2016-02-27 00:48:29 -08:00
parent a1c4e6d0ab
commit af65fbea63

View file

@ -211,7 +211,6 @@ function symbol (unquoted)."
(not (eq (car (cdr (cdr args))) :map)))
(setq args (cons :map (cons 'global-map args))))
(let* ((map (plist-get args :map))
(maps (if (listp map) map (list map)))
(doc (plist-get args :prefix-docstring))
(prefix-map (plist-get args :prefix-map))
(prefix (plist-get args :prefix))
@ -239,13 +238,15 @@ function symbol (unquoted)."
(nconc first (list (car args)))
(setq first (list (car args))))
(setq args (cdr args))))
(cl-flet ((wrap (maps bindings)
(if (and maps pkg
(not (equal maps '(global-map))))
`((eval-after-load
,(if (symbolp pkg) `',pkg pkg)
'(progn ,@bindings)))
bindings)))
(cl-flet
((wrap (map bindings)
(if (and map pkg (not (eq map 'global-map)))
(if (boundp map)
bindings
`((eval-after-load
,(if (symbolp pkg) `',pkg pkg)
'(progn ,@bindings))))
bindings)))
(append
(when prefix-map
`((defvar ,prefix-map)
@ -253,23 +254,16 @@ function symbol (unquoted)."
,@(if menu-name
`((define-prefix-command ',prefix-map nil ,menu-name))
`((define-prefix-command ',prefix-map)))
,@(if (and maps (not (equal maps '(global-map))))
(wrap maps
(mapcar
#'(lambda (m)
`(bind-key ,prefix ',prefix-map ,m ,filter))
maps))
,@(if (and map (not (eq map 'global-map)))
(wrap map `((bind-key ,prefix ',prefix-map ,map ,filter)))
`((bind-key ,prefix ',prefix-map nil ,filter)))))
(wrap maps
(wrap map
(cl-mapcan
(lambda (form)
(if prefix-map
`((bind-key ,(car form) ',(cdr form) ,prefix-map ,filter))
(if (and maps (not (equal maps '(global-map))))
(mapcar
#'(lambda (m)
`(bind-key ,(car form) ',(cdr form) ,m ,filter))
maps)
(if (and map (not (eq map 'global-map)))
`((bind-key ,(car form) ',(cdr form) ,map ,filter))
`((bind-key ,(car form) ',(cdr form) nil ,filter)))))
first))
(when next