diff options
author | John Wiegley <johnw@newartisans.com> | 2017-12-05 13:11:30 -0800 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2017-12-05 13:11:30 -0800 |
commit | 65caa3b423e9a535568d3a60551f412916ce4c1f (patch) | |
tree | 303918dbefe59a369fb8912e9e3267d3669e76c8 /lisp/use-package/use-package-bind-key.el | |
parent | 725d749b7c76f2a8c786922dc72cca5ae5e56e50 (diff) | |
download | emacs-65caa3b423e9a535568d3a60551f412916ce4c1f.tar.gz emacs-65caa3b423e9a535568d3a60551f412916ce4c1f.tar.bz2 emacs-65caa3b423e9a535568d3a60551f412916ce4c1f.zip |
Rewrite normalization of :bind and :bind*
Fixes https://github.com/jwiegley/use-package/issues/550
Diffstat (limited to 'lisp/use-package/use-package-bind-key.el')
-rw-r--r-- | lisp/use-package/use-package-bind-key.el | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/lisp/use-package/use-package-bind-key.el b/lisp/use-package/use-package-bind-key.el index 09229153f0c..7c5d2725301 100644 --- a/lisp/use-package/use-package-bind-key.el +++ b/lisp/use-package/use-package-bind-key.el @@ -67,17 +67,44 @@ deferred until the prefix key sequence is pressed." package keymap-symbol))))) (defun use-package-normalize-binder (name keyword args) - (use-package-as-one (symbol-name keyword) args - #'(lambda (label arg) - (unless (consp arg) + (let ((arg args) + args*) + (while arg + (let ((x (car arg))) + (cond + ;; (KEY . COMMAND) + ((and (consp x) + (or (stringp (car x)) + (vectorp (car x))) + (or (use-package-recognize-function (cdr x) t #'stringp))) + (setq args* (nconc args* (list x))) + (setq arg (cdr arg))) + ;; KEYWORD + ;; :map KEYMAP + ;; :prefix-docstring STRING + ;; :prefix-map SYMBOL + ;; :prefix STRING + ;; :filter SEXP + ;; :menu-name STRING + ((or (and (eq x :map) (symbolp (cadr arg))) + (and (eq x :prefix) (stringp (cadr arg))) + (and (eq x :prefix-map) (symbolp (cadr arg))) + (and (eq x :prefix-docstring) (stringp (cadr arg))) + (eq x :filter) + (and (eq x :menu-name) (stringp (cadr arg)))) + (setq args* (nconc args* (list x (cadr arg)))) + (setq arg (cddr arg))) + ((listp x) + (setq args* + (nconc args* (use-package-normalize-binder name keyword x))) + (setq arg (cdr arg))) + (t + ;; Error! (use-package-error - (concat label " a (<string or vector> . <symbol, string or function>)" - " or list of these"))) - (use-package-normalize-pairs - #'(lambda (k) (cond ((stringp k) t) - ((vectorp k) t))) - #'(lambda (v) (use-package-recognize-function v t #'stringp)) - name label arg)))) + (concat (symbol-name name) + " wants arguments acceptable to the `bind-keys' macro," + " or a list of such values")))))) + args*)) ;;;; :bind, :bind* |