[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/which-key 465d2fb 10/32: Fix add-keymap-based-bindings
From: |
ELPA Syncer |
Subject: |
[elpa] externals/which-key 465d2fb 10/32: Fix add-keymap-based-bindings and associated test |
Date: |
Wed, 30 Jun 2021 18:57:28 -0400 (EDT) |
branch: externals/which-key
commit 465d2fb2e4540257ad515f37f2cb4e419b286f8c
Author: Justin Burkett <justin@burkett.cc>
Commit: Justin Burkett <justin@burkett.cc>
Fix add-keymap-based-bindings and associated test
---
which-key-tests.el | 25 +++++++++++--------------
which-key.el | 12 +++++++-----
2 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/which-key-tests.el b/which-key-tests.el
index eeedb55..0461737 100644
--- a/which-key-tests.el
+++ b/which-key-tests.el
@@ -29,20 +29,17 @@
(ert-deftest which-key-test--keymap-based-bindings ()
(let ((map (make-sparse-keymap))
- (emacs-lisp-mode-map (copy-keymap emacs-lisp-mode-map)))
- (emacs-lisp-mode)
- (define-key map "x" 'ignore)
- (define-key emacs-lisp-mode-map "\C-c\C-a" 'complete)
- (define-key emacs-lisp-mode-map "\C-c\C-b" map)
- (which-key-add-keymap-based-replacements emacs-lisp-mode-map
- "C-c C-a" '("mycomplete" . complete)
- "C-c C-b" "mymap")
- (should (equal
- (which-key--maybe-replace '("C-c C-a" . "complete"))
- '("C-c C-a" . "mycomplete")))
- (should (equal
- (which-key--maybe-replace '("C-c C-b" . ""))
- '("C-c C-b" . "mymap")))))
+ (prefix-map (make-sparse-keymap)))
+ (define-key prefix-map "x" 'ignore)
+ (define-key map "\C-a" 'complete)
+ (define-key map "\C-b" prefix-map)
+ (which-key-add-keymap-based-replacements map
+ "C-a" '("mycomplete" . complete)
+ "C-b" "mymap")
+ (should (equal
+ (which-key--get-keymap-bindings map)
+ '(("C-a" . "mycomplete")
+ ("C-b" . "mymap"))))))
(ert-deftest which-key-test--prefix-declaration ()
"Test `which-key-declare-prefixes' and
diff --git a/which-key.el b/which-key.el
index d6baa70..ec3f760 100644
--- a/which-key.el
+++ b/which-key.el
@@ -914,11 +914,13 @@ both have the same effect for the \"C-x C-w\" key
binding, but
the latter causes which-key to verify that the key sequence is
actually bound to write-file before performing the replacement."
(while key
- (let ((string (if (stringp replacement)
- replacement
- (car-safe replacement)))
- (command (cdr-safe replacement)))
- (define-key keymap (kbd key) (cons string command)))
+ (cond ((consp replacement)
+ (define-key keymap (kbd key) replacement))
+ ((stringp replacement)
+ (define-key keymap (kbd key) (cons replacement
+ (lookup-key keymap (kbd key)))))
+ (t
+ (user-error "replacement is neither a cons cell or a string")))
(setq key (pop more)
replacement (pop more))))
(put 'which-key-add-keymap-based-replacements 'lisp-indent-function 'defun)
- [elpa] externals/which-key 11471fb 21/32: Add install python step to github action, (continued)
- [elpa] externals/which-key 11471fb 21/32: Add install python step to github action, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key e236920 14/32: Merge branch 'alt-get-bindings', ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 7cfbf8c 23/32: Turn off fail-fast in github action, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key eb5a2e3 28/32: Clean up some docstrings, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key cd0c48c 29/32: Clarify usage of keymap replacements in docstrings and README, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 27d9fec 32/32: Fix compiler warnings, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 4c27fc0 30/32: Improve which-key-add-keymap-based-replacements., ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 8a558e6 06/32: Update tests, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key e42d946 11/32: Fix prefix sorting, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key fc88551 05/32: Remove pseudo binding stuff, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 465d2fb 10/32: Fix add-keymap-based-bindings and associated test,
ELPA Syncer <=
- [elpa] externals/which-key 6ae80f5 22/32: Try without cask, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key d621634 19/32: Try with cask again, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key a55b908 04/32: Alternative approach to retrieving bindings (WIP), ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 1f9c37d 03/32: Merge pull request #305 from tarsiiformes/first-line, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 4e592ed 08/32: Fix type usage and arglists for new functions, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key d6b56f3 13/32: Fix detection of named prefix bindings, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 2444833 12/32: Fix menu-item bidning retrieval, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 7d344ce 17/32: Fix test, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 300c098 16/32: Update README, ELPA Syncer, 2021/06/30
- [elpa] externals/which-key 3f76f51 20/32: Fix which-key--group-p, ELPA Syncer, 2021/06/30