Skip to content

Commit

Permalink
Merge branch 'alt-get-bindings'
Browse files Browse the repository at this point in the history
  • Loading branch information
justbur committed Jun 21, 2021
2 parents 1f9c37d + d6b56f3 commit e236920
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 226 deletions.
1 change: 1 addition & 0 deletions Cask
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
(package-file "which-key.el")

(development
(depends-on "evil")
(depends-on "ert"))
52 changes: 32 additions & 20 deletions which-key-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -141,25 +138,40 @@

(ert-deftest which-key-test--get-keymap-bindings ()
(let ((map (make-sparse-keymap))
(evil-local-mode t)
(evil-state 'normal)
which-key-replacement-alist)
(require 'evil)
(define-key map [which-key-a] '(which-key "blah"))
(define-key map "b" 'ignore)
(define-key map "c" "c")
(define-key map "dd" "dd")
(define-key map "eee" "eee")
(define-key map "f" [123 45 6])
(define-key map (kbd "M-g g") "M-gg")
(evil-define-key* 'normal map (kbd "C-h") "C-h-normal")
(evil-define-key* 'insert map (kbd "C-h") "C-h-insert")
(should (equal
(sort (which-key--get-keymap-bindings map)
(lambda (a b) (string-lessp (car a) (car b))))
'(("b" . "ignore")
'(("M-g" . "prefix")
("c" . "c")
("d" . "prefix")
("e" . "prefix")
("f" . "{ - C-f"))))
(should (equal
(sort (which-key--get-keymap-bindings map nil nil nil nil t)
(lambda (a b) (string-lessp (car a) (car b))))
'(("C-h" . "C-h-normal")
("M-g" . "prefix")
("c" . "c")
("d" . "Prefix Command")
("e" . "Prefix Command")
("d" . "prefix")
("e" . "prefix")
("f" . "{ - C-f"))))
(should (equal
(sort (which-key--get-keymap-bindings map t)
(sort (which-key--get-keymap-bindings map nil nil nil t)
(lambda (a b) (string-lessp (car a) (car b))))
'(("b" . "ignore")
'(("M-g g" . "M-gg")
("c" . "c")
("d d" . "dd")
("e e e" . "eee")
Expand All @@ -177,7 +189,7 @@
("A" . "Z")
("b" . "y")
("B" . "Y")
("p" . "Prefix")
("p" . "prefix")
("SPC" . "x")
("C-a" . "w"))))
(let ((which-key-sort-uppercase-first t))
Expand Down
Loading

0 comments on commit e236920

Please sign in to comment.