(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))
(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)
,@(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