From a090961f105595b6c9b56c0e5cda567c76687b06 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 5 Dec 2017 10:29:04 -0800 Subject: [PATCH] Fix bad interaction between bind-keys* and the :package keyword Fixes https://github.com/jwiegley/use-package/issues/558 --- lisp/use-package/bind-key.el | 9 +++++---- test/lisp/use-package/use-package-tests.el | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lisp/use-package/bind-key.el b/lisp/use-package/bind-key.el index 54961ecd96e..f5477945b4b 100644 --- a/lisp/use-package/bind-key.el +++ b/lisp/use-package/bind-key.el @@ -222,8 +222,10 @@ function symbol (unquoted)." ;; 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. (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)))) + (let ((map keymap) doc prefix-map @@ -267,7 +269,7 @@ function symbol (unquoted)." (cl-flet ((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) (progn ,@bindings) (eval-after-load @@ -320,8 +322,7 @@ function symbol (unquoted)." ;;;###autoload (defmacro bind-keys* (&rest args) - (macroexp-progn - (bind-keys-form args 'override-global-map))) + (macroexp-progn (bind-keys-form args 'override-global-map))) (defun get-binding-description (elem) (cond diff --git a/test/lisp/use-package/use-package-tests.el b/test/lisp/use-package/use-package-tests.el index 938e990b856..67d7c6f7e4d 100644 --- a/test/lisp/use-package/use-package-tests.el +++ b/test/lisp/use-package/use-package-tests.el @@ -1477,6 +1477,12 @@ (use-package-ensure-elpa 'hydra '(t) '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 () (match-expansion (bind-keys :prefix "" -- 2.39.2