]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix a scoping issues with multiple occurrences of :bind
authorJohn Wiegley <johnw@newartisans.com>
Sun, 10 Dec 2017 00:28:49 +0000 (16:28 -0800)
committerJohn Wiegley <johnw@newartisans.com>
Sun, 10 Dec 2017 00:29:11 +0000 (16:29 -0800)
Fixes https://github.com/jwiegley/use-package/issues/585

lisp/use-package/use-package-bind-key.el
lisp/use-package/use-package-core.el
test/lisp/use-package/use-package-tests.el

index b26c812bf5875ca840b2a3a78e4d0971625f7574..d8fe56dfaa5e07537ad8370f92adf8306dc00233 100644 (file)
@@ -128,8 +128,11 @@ deferred until the prefix key sequence is pressed."
     (name keyword args rest state &optional bind-macro)
   (use-package-concat
    (use-package-process-keywords name rest state)
-   `((,(if bind-macro bind-macro 'bind-keys)
-      :package ,name ,@(use-package-normalize-commands args)))))
+   `(,@(mapcar
+        #'(lambda (xs)
+            `(,(if bind-macro bind-macro 'bind-keys)
+              :package ,name ,@(use-package-normalize-commands xs)))
+        (use-package-split-list-at-keys :break args)))))
 
 (defun use-package-handler/:bind* (name keyword arg rest state)
   (use-package-handler/:bind name keyword arg rest state 'bind-keys*))
index e700c1c110b71ab2669ccbab77c506876e9d9d60..df65e04b9a055f100ab87f1a2596e4a743cf9610 100644 (file)
@@ -180,7 +180,8 @@ t according to whether defaulting should be attempted."
 (defcustom use-package-merge-key-alist
   '((:if    . (lambda (new old) `(and ,new ,old)))
     (:after . (lambda (new old) `(:all ,new ,old)))
-    (:defer . (lambda (new old) old)))
+    (:defer . (lambda (new old) old))
+    (:bind  . (lambda (new old) (append new (list :break) old))))
   "Alist of keys and the functions used to merge multiple values.
 For example, if the following form is provided:
 
@@ -472,6 +473,13 @@ This is in contrast to merely setting it to 0."
           (nconc ys (list x)))))
     (cons (cdr ys) (cdr zs))))
 
+(defun use-package-split-list-at-keys (key lst)
+  (when lst
+    (let* ((xs (use-package-split-list (apply-partially #'eq key) lst))
+           (args (car xs))
+           (tail (cdr xs)))
+      (cons args (use-package-split-list-at-keys key (cdr tail))))))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;
 ;;; Keywords
index 5ba6db8a4b59a1926d91055bb809e13022beb2b1..5aab6bb117043fc6b0f380dd8b0cda43bdeb4540 100644 (file)
            t))
       (bind-keys :package helm ("C-c d" . helm-mini)))))
 
+(ert-deftest use-package-test/585 ()
+  (match-expansion
+   (use-package bug
+     :bind (:map bug-map ("C-a" . alpha))
+     :bind (("C-b" . beta)))
+   `(progn
+      (unless (fboundp 'alpha)
+        (autoload #'alpha "bug" nil t))
+      (unless (fboundp 'beta)
+        (autoload #'beta "bug" nil t))
+      (bind-keys :package bug :map bug-map
+                 ("C-a" . alpha))
+      (bind-keys :package bug
+                 ("C-b" . beta)))))
+
 (ert-deftest bind-key/:prefix-map ()
   (match-expansion
    (bind-keys :prefix "<f1>"