Fix bad interaction between bind-keys* and the :package keyword

Fixes https://github.com/jwiegley/use-package/issues/558
This commit is contained in:
John Wiegley 2017-12-05 10:29:04 -08:00
parent 10fd4577d0
commit a090961f10
2 changed files with 11 additions and 4 deletions

View file

@ -222,8 +222,10 @@ function symbol (unquoted)."
;; jww (2016-02-26): This is a hack; this whole function needs to be ;; jww (2016-02-26): This is a hack; this whole function needs to be
;; rewritten to normalize arguments the way that use-package.el does. ;; rewritten to normalize arguments the way that use-package.el does.
(if (and (eq (car args) :package) (if (and (eq (car args) :package)
(not (eq (car (cdr (cdr args))) :map))) (not (eq (car (cdr (cdr args))) :map))
(not keymap))
(setq args (cons :map (cons 'global-map args)))) (setq args (cons :map (cons 'global-map args))))
(let ((map keymap) (let ((map keymap)
doc doc
prefix-map prefix-map
@ -267,7 +269,7 @@ function symbol (unquoted)."
(cl-flet (cl-flet
((wrap (map bindings) ((wrap (map bindings)
(if (and map pkg (not (eq map 'global-map))) (if (and map pkg (not (memq map '(global-map override-global-map))))
`((if (boundp ',map) `((if (boundp ',map)
(progn ,@bindings) (progn ,@bindings)
(eval-after-load (eval-after-load
@ -320,8 +322,7 @@ function symbol (unquoted)."
;;;###autoload ;;;###autoload
(defmacro bind-keys* (&rest args) (defmacro bind-keys* (&rest args)
(macroexp-progn (macroexp-progn (bind-keys-form args 'override-global-map)))
(bind-keys-form args 'override-global-map)))
(defun get-binding-description (elem) (defun get-binding-description (elem)
(cond (cond

View file

@ -1477,6 +1477,12 @@
(use-package-ensure-elpa 'hydra '(t) 'nil) (use-package-ensure-elpa 'hydra '(t) 'nil)
(require 'hydra nil nil)))) (require 'hydra nil nil))))
(ert-deftest use-package-test/558 ()
(match-expansion
(bind-keys* :package org-ref
("C-c C-r" . org-ref-helm-insert-cite-link))
`(bind-key "C-c C-r" #'org-ref-helm-insert-cite-link override-global-map nil)))
(ert-deftest bind-key/:prefix-map () (ert-deftest bind-key/:prefix-map ()
(match-expansion (match-expansion
(bind-keys :prefix "<f1>" (bind-keys :prefix "<f1>"