aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJacob First2022-09-29 02:36:43 -0400
committerJacob First2022-09-29 04:01:42 -0400
commitec96b4766418fdfce2d7827fa6ddeb7257ad6cf7 (patch)
treed76d81dea03592d3ba3e5211292b9b7bdb67d199 /test
parentdaa124e1cc5ea0154f47f7ee271b8922a51c1be8 (diff)
downloademacs-ec96b4766418fdfce2d7827fa6ddeb7257ad6cf7.tar.gz
emacs-ec96b4766418fdfce2d7827fa6ddeb7257ad6cf7.zip
bind-keys supports passing a list of keymaps as :map argument
Diffstat (limited to 'test')
-rw-r--r--test/lisp/use-package/use-package-tests.el85
1 files changed, 81 insertions, 4 deletions
diff --git a/test/lisp/use-package/use-package-tests.el b/test/lisp/use-package/use-package-tests.el
index 9510fffb01c..007d2b07ac8 100644
--- a/test/lisp/use-package/use-package-tests.el
+++ b/test/lisp/use-package/use-package-tests.el
@@ -1951,15 +1951,92 @@
1951 (autoload #'nonexistent-mode "nonexistent" nil t)) 1951 (autoload #'nonexistent-mode "nonexistent" nil t))
1952 (add-hook 'lisp-mode-hook #'nonexistent-mode))))) 1952 (add-hook 'lisp-mode-hook #'nonexistent-mode)))))
1953 1953
1954(ert-deftest bind-key/:map ()
1955 (match-expansion
1956 (bind-keys
1957 ("C-1" . command-1)
1958 ("C-2" . command-2)
1959 :map keymap-1
1960 ("C-3" . command-3)
1961 ("C-4" . command-4)
1962 :map (keymap-2 keymap-3)
1963 ("C-5" . command-5)
1964 ("C-6" . command-6))
1965 `(progn (bind-key "C-1" #'command-1 nil nil)
1966 (bind-key "C-2" #'command-2 nil nil)
1967 (bind-key "C-3" #'command-3 keymap-1 nil)
1968 (bind-key "C-4" #'command-4 keymap-1 nil)
1969 (bind-key "C-5" #'command-5 keymap-2 nil)
1970 (bind-key "C-6" #'command-6 keymap-2 nil)
1971 (bind-key "C-5" #'command-5 keymap-3 nil)
1972 (bind-key "C-6" #'command-6 keymap-3 nil))))
1973
1954(ert-deftest bind-key/:prefix-map () 1974(ert-deftest bind-key/:prefix-map ()
1955 (match-expansion 1975 (match-expansion
1956 (bind-keys :prefix "<f1>" 1976 (bind-keys ("C-1" . command-1)
1957 :prefix-map my/map) 1977 :prefix "<f1>"
1978 :prefix-map my/map
1979 ("C-2" . command-2)
1980 ("C-3" . command-3))
1958 `(progn 1981 `(progn
1982 (bind-key "C-1" #'command-1 nil nil)
1959 (defvar my/map) 1983 (defvar my/map)
1960 (define-prefix-command 'my/map) 1984 (define-prefix-command 'my/map)
1961 (bind-key "<f1>" 'my/map nil nil)))) 1985 (bind-key "<f1>" 'my/map nil nil)
1962 1986 (bind-key "C-2" #'command-2 my/map nil)
1987 (bind-key "C-3" #'command-3 my/map nil))))
1988
1989(ert-deftest bind-key/:repeat-map-1 ()
1990 ;; NOTE: This test is pulled from the discussion in issue #964,
1991 ;; adjusting for the final syntax that was implemented.
1992 (match-expansion
1993 (bind-keys
1994 ("C-c n" . git-gutter+-next-hunk)
1995 ("C-c p" . git-gutter+-previous-hunk)
1996 ("C-c s" . git-gutter+-stage-hunks)
1997 ("C-c r" . git-gutter+-revert-hunk)
1998 :repeat-map my/git-gutter+-repeat-map
1999 ("n" . git-gutter+-next-hunk)
2000 ("p" . git-gutter+-previous-hunk)
2001 ("s" . git-gutter+-stage-hunks)
2002 ("r" . git-gutter+-revert-hunk)
2003 :repeat-docstring
2004 "Keymap to repeat git-gutter+-* commands.")
2005 `(progn
2006 (bind-key "C-c n" #'git-gutter+-next-hunk nil nil)
2007 (bind-key "C-c p" #'git-gutter+-previous-hunk nil nil)
2008 (bind-key "C-c s" #'git-gutter+-stage-hunks nil nil)
2009 (bind-key "C-c r" #'git-gutter+-revert-hunk nil nil)
2010 (defvar my/git-gutter+-repeat-map (make-sparse-keymap))
2011 (put #'git-gutter+-next-hunk 'repeat-map 'my/git-gutter+-repeat-map)
2012 (bind-key "n" #'git-gutter+-next-hunk my/git-gutter+-repeat-map nil)
2013 (put #'git-gutter+-previous-hunk 'repeat-map 'my/git-gutter+-repeat-map)
2014 (bind-key "p" #'git-gutter+-previous-hunk my/git-gutter+-repeat-map nil)
2015 (put #'git-gutter+-stage-hunks 'repeat-map 'my/git-gutter+-repeat-map)
2016 (bind-key "s" #'git-gutter+-stage-hunks my/git-gutter+-repeat-map nil)
2017 (put #'git-gutter+-revert-hunk 'repeat-map 'my/git-gutter+-repeat-map)
2018 (bind-key "r" #'git-gutter+-revert-hunk my/git-gutter+-repeat-map nil)
2019 (defvar my/git-gutter+-repeat-map (make-sparse-keymap) "Keymap to repeat git-gutter+-* commands."))))
2020
2021(ert-deftest bind-key/:repeat-map-2 ()
2022 (match-expansion
2023 (bind-keys :map m ("x" . cmd1) :repeat-map rm ("y" . cmd2))
2024 `(progn
2025 (bind-key "x" #'cmd1 m nil)
2026 (defvar rm (make-sparse-keymap))
2027 (put #'cmd2 'repeat-map 'rm)
2028 (bind-key "y" #'cmd2 rm nil))))
2029
2030(ert-deftest bind-key/:repeat-map-3 ()
2031 (match-expansion
2032 (bind-keys :repeat-map rm ("y" . cmd2) :map m ("x" . cmd1))
2033 `(progn
2034 (defvar rm (make-sparse-keymap))
2035 (put #'cmd2 'repeat-map 'rm)
2036 (bind-key "y" #'cmd2 rm nil)
2037 (defvar rm (make-sparse-keymap))
2038 (put #'cmd1 'repeat-map 'rm)
2039 (bind-key "x" #'cmd1 m nil))))
1963 2040
1964(ert-deftest bind-key/845 () 2041(ert-deftest bind-key/845 ()
1965 (defvar test-map (make-keymap)) 2042 (defvar test-map (make-keymap))