(wrap map
(cl-mapcan
(lambda (form)
- (if prefix-map
- `((bind-key ,(car form) #',(cdr form) ,prefix-map ,filter))
- (if (and map (not (eq map 'global-map)))
- `((bind-key ,(car form) #',(cdr form) ,map ,filter))
- `((bind-key ,(car form) #',(cdr form) nil ,filter)))))
+ (let ((fun (and (cdr form) (list 'function (cdr form)))))
+ (if prefix-map
+ `((bind-key ,(car form) ,fun ,prefix-map ,filter))
+ (if (and map (not (eq map 'global-map)))
+ `((bind-key ,(car form) ,fun ,map ,filter))
+ `((bind-key ,(car form) ,fun nil ,filter))))))
first))
(when next
(bind-keys-form
(defun use-package--recognize-function (v &optional additional-pred)
"A predicate that recognizes functional constructions:
+ nil
sym
'sym
(quote sym)
#'(lambda () ...)
(function (lambda () ...))"
(pcase v
- ((pred use-package--non-nil-symbolp) t)
+ ((pred symbolp) t)
(`(,(or `quote `function)
- ,(pred use-package--non-nil-symbolp)) t)
- ((pred functionp) t)
- (`(function (lambda . ,_)) t)
+ ,(pred symbolp)) t)
+ ((pred commandp) t)
(_ (and additional-pred
(funcall additional-pred v)))))
sym
#'(lambda () ...)"
(pcase v
- ((pred use-package--non-nil-symbolp) v)
+ ((pred symbolp) v)
(`(,(or `quote `function)
- ,(and sym (pred use-package--non-nil-symbolp))) sym)
+ ,(and sym (pred symbolp))) sym)
(`(lambda . ,_) v)
(`(quote ,(and lam `(lambda . ,_))) lam)
(`(function ,(and lam `(lambda . ,_))) lam)
(use-package--normalize-function (cdr x)))
x)) args)))
(cons nargs
- (delete nil (mapcar #'(lambda (x)
- (and (consp x)
- (use-package--non-nil-symbolp (cdr x))
- (cdr x))) nargs)))))
+ (delete
+ nil (mapcar
+ #'(lambda (x)
+ (and (consp x)
+ (use-package--non-nil-symbolp (cdr x))
+ (cdr x))) nargs)))))
(defun use-package-normalize-binder (name keyword args)
(use-package-as-one (symbol-name keyword) args
(lambda (def)
(let ((syms (car def))
(fun (cdr def)))
- (mapcar
- #'(lambda (sym)
- `(add-hook (quote ,(intern (format "%s-hook" sym)))
- (function ,fun)))
- (if (use-package--non-nil-symbolp syms) (list syms) syms))))
+ (when fun
+ (mapcar
+ #'(lambda (sym)
+ `(add-hook (quote ,(intern (format "%s-hook" sym)))
+ (function ,fun)))
+ (if (use-package--non-nil-symbolp syms) (list syms) syms)))))
nargs))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;