summaryrefslogtreecommitdiff
path: root/lisp/use-package/use-package.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2015-03-16 03:19:28 -0500
committerJohn Wiegley <johnw@newartisans.com>2015-03-16 03:19:28 -0500
commit05c02aee865762ef7b5dd1a3a39df7b3c4f29606 (patch)
treeac8e84b7494532217f28e201eecb03bf3962dbc1 /lisp/use-package/use-package.el
parent55d6bb00cac8bab2be81e16ca62fca28fc83af6b (diff)
downloademacs-05c02aee865762ef7b5dd1a3a39df7b3c4f29606.tar.gz
emacs-05c02aee865762ef7b5dd1a3a39df7b3c4f29606.tar.bz2
emacs-05c02aee865762ef7b5dd1a3a39df7b3c4f29606.zip
Allow vectors to be passed to :bind again
Fixes https://github.com/jwiegley/use-package/issues/166
Diffstat (limited to 'lisp/use-package/use-package.el')
-rw-r--r--lisp/use-package/use-package.el21
1 files changed, 14 insertions, 7 deletions
diff --git a/lisp/use-package/use-package.el b/lisp/use-package/use-package.el
index a619ded7727..b7ef29aae0e 100644
--- a/lisp/use-package/use-package.el
+++ b/lisp/use-package/use-package.el
@@ -187,22 +187,24 @@ the user specified.")
(use-package-error
(concat label " wants a list"))))
-(defsubst use-package-is-sympair (x)
+(defsubst use-package-is-sympair (x &optional allow-vector)
"Return t if X has the type (STRING . SYMBOL)."
(and (consp x)
- (stringp (car x))
+ (or (stringp (car x))
+ (and allow-vector (vectorp (car x))))
(symbolp (cdr x))))
-(defun use-package-normalize-pairs (name-symbol label arg &optional recursed)
+(defun use-package-normalize-pairs
+ (name-symbol label arg &optional recursed allow-vector)
"Normalize a list of string/symbol pairs."
(cond
- ((stringp arg)
+ ((or (stringp arg) (and allow-vector (vectorp arg)))
(list (cons arg name-symbol)))
- ((use-package-is-sympair arg)
+ ((use-package-is-sympair arg allow-vector)
(list arg))
((and (not recursed) (listp arg) (listp (cdr arg)))
(mapcar #'(lambda (x) (car (use-package-normalize-pairs
- name-symbol label x t))) arg))
+ name-symbol label x t allow-vector))) arg))
(t
(use-package-error
(concat label " wants a string, (string . symbol) or list of these")))))
@@ -261,7 +263,12 @@ the user specified.")
(cond ((memq head '(:when :unless)) :if)
(t head))
(pcase head
- ((or :bind :bind* :bind-keymap :bind-keymap* :interpreter :mode)
+ ((or :bind :bind* :bind-keymap :bind-keymap*)
+ (use-package-as-one (symbol-name head) args
+ (lambda (label arg)
+ (use-package-normalize-pairs name-symbol label arg nil t))))
+
+ ((or :interpreter :mode)
(use-package-as-one (symbol-name head) args
(apply-partially #'use-package-normalize-pairs name-symbol)))