|
101 | 101 | "Emulate pressing keys decoded from SEQ." |
102 | 102 | (if (vectorp seq) |
103 | 103 | (lispy--unalias-key seq) |
104 | | - (let ((keys (lispy-decode-keysequence seq)) |
| 104 | + (let ((lkeys (lispy-decode-keysequence seq)) |
105 | 105 | key) |
106 | | - (while (setq key (pop keys)) |
| 106 | + (while (setq key (pop lkeys)) |
107 | 107 | (if (numberp key) |
108 | 108 | (let ((current-prefix-arg (list key))) |
109 | | - (when keys |
110 | | - (lispy--unalias-key (pop keys)))) |
| 109 | + (when lkeys |
| 110 | + (lispy--unalias-key (pop lkeys)))) |
111 | 111 | (lispy--unalias-key key)))))) |
112 | 112 |
|
113 | 113 | (defun lispy--unalias-key (key) |
114 | 114 | "Call command that corresponds to KEY. |
115 | 115 | Insert KEY if there's no command." |
116 | | - (let ((cmd (cdr (assoc 'lispy-mode (minor-mode-key-binding key))))) |
| 116 | + (let ((cmd (cdr (or (assoc 'lispy-mode (minor-mode-key-binding key)) |
| 117 | + (assoc 'lispy-other-mode (minor-mode-key-binding key)))))) |
117 | 118 | (if (or (and cmd (or (looking-at lispy-left) |
118 | 119 | (looking-back lispy-right) |
119 | 120 | (looking-at lispy-outline) |
@@ -718,10 +719,10 @@ Insert KEY if there's no command." |
718 | 719 | "\"a series| of strings\"")) |
719 | 720 | (should (string= (lispy-with "\"a series|\"\n \" of strings\"" (kbd "M-J")) |
720 | 721 | "\"a series| of strings\"")) |
721 | | - (should (string= (lispy-with "\"a s|eries|\"\n \" of strings\"" (kbd "M-J")) |
722 | | - "\"a s|eries| of strings\"")) |
723 | | - (should (string= (lispy-with "|\"a s|eries|\"\n \" of strings\"" (kbd "M-J")) |
724 | | - "|\"a s|eries| of strings\""))) |
| 722 | + (should (string= (lispy-with "\"a series|\"\n \" of strings\"" (kbd "M-J")) |
| 723 | + "\"a series| of strings\"")) |
| 724 | + (should (string= (lispy-with "|\"a series\"\n \" of strings\"" (kbd "M-J")) |
| 725 | + "|\"a series of strings\""))) |
725 | 726 |
|
726 | 727 | (ert-deftest lispy-split () |
727 | 728 | (should (string= (lispy-with "(foo |bar)" (kbd "M-j")) |
@@ -764,8 +765,8 @@ Insert KEY if there's no command." |
764 | 765 | (should (string= (lispy-with "((a) |(b) (c))" "mjw") |
765 | 766 | "((a) ~(c)| (b))")) |
766 | 767 | (should (string= (lispy-with "(foo b|ar)" |
767 | | - (lispy-mark-symbol) |
768 | | - (lispy-move-up 1)) |
| 768 | + (kbd "M-m") |
| 769 | + "w") |
769 | 770 | "(~bar| foo)")) |
770 | 771 | (should (string= (lispy-with "(put :foo 1\n :bar 2\n |:baz '(1 2 3)~)" |
771 | 772 | (lispy-move-up 2)) |
@@ -796,8 +797,8 @@ Insert KEY if there's no command." |
796 | 797 | (should (string= (lispy-with "(|(a) (b) (c))" "m]s") |
797 | 798 | "((c) ~(a) (b)|)")) |
798 | 799 | (should (string= (lispy-with "(f|oo bar)" |
799 | | - (lispy-mark-symbol) |
800 | | - (lispy-move-down 1)) |
| 800 | + (kbd "M-m") |
| 801 | + "s") |
801 | 802 | "(bar ~foo|)")) |
802 | 803 | (should (string= (lispy-with "(put :foo 1\n ~:baz '(1 2 3)|\n :bar 2)" |
803 | 804 | (lispy-move-down 2)) |
@@ -964,19 +965,19 @@ Insert KEY if there's no command." |
964 | 965 | "(->> [1 2 3 4 5]\n (map sqr)\n (filter odd?))|"))) |
965 | 966 |
|
966 | 967 | (ert-deftest lispy-mark () |
967 | | - (should (string= (lispy-with "|;; abc\n;; def\n;; ghi" (lispy-mark)) |
| 968 | + (should (string= (lispy-with "|;; abc\n;; def\n;; ghi" (kbd "C-M-,")) |
968 | 969 | "~;; abc\n;; def\n;; ghi|")) |
969 | | - (should (string= (lispy-with ";; a|bc\n;; def\n;; ghi" (lispy-mark)) |
| 970 | + (should (string= (lispy-with ";; a|bc\n;; def\n;; ghi" (kbd "C-M-,")) |
970 | 971 | "~;; abc\n;; def\n;; ghi|")) |
971 | | - (should (string= (lispy-with ";; abc\n|;; def\n;; ghi" (lispy-mark)) |
| 972 | + (should (string= (lispy-with ";; abc\n|;; def\n;; ghi" (kbd "C-M-,")) |
972 | 973 | "~;; abc\n;; def\n;; ghi|")) |
973 | | - (should (string= (lispy-with ";; abc\n;; def\n;; ghi|" (lispy-mark)) |
| 974 | + (should (string= (lispy-with ";; abc\n;; def\n;; ghi|" (kbd "C-M-,")) |
974 | 975 | "~;; abc\n;; def\n;; ghi|"))) |
975 | 976 |
|
976 | 977 | (ert-deftest lispy-mark-symbol () |
977 | | - (should (string= (lispy-with "(foo |\"bar\")" (lispy-mark-symbol)) |
| 978 | + (should (string= (lispy-with "(foo |\"bar\")" (kbd "M-m")) |
978 | 979 | "(foo ~\"bar\"|)")) |
979 | | - (should (string= (lispy-with "(foo \"bar|\")" (lispy-mark-symbol)) |
| 980 | + (should (string= (lispy-with "(foo \"bar|\")" (kbd "M-m")) |
980 | 981 | "(foo ~\"bar\"|)")) |
981 | 982 | (should (string= (lispy-with "(mapc #'ta|unt knights)" (kbd "M-m")) |
982 | 983 | "(mapc ~#'taunt| knights)"))) |
@@ -1065,17 +1066,17 @@ Insert KEY if there's no command." |
1065 | 1066 | "(defun foo ()\n |)"))) |
1066 | 1067 |
|
1067 | 1068 | (ert-deftest lispy-up-slurp () |
1068 | | - (should (string= (lispy-with "(progn\n (foo))\n|(bar)" (lispy-up-slurp)) |
| 1069 | + (should (string= (lispy-with "(progn\n (foo))\n|(bar)" "ok") |
1069 | 1070 | "(progn\n (foo)\n |(bar))")) |
1070 | | - (should (string= (lispy-with "(progn\n (foo))\n(bar)|" (lispy-up-slurp)) |
| 1071 | + (should (string= (lispy-with "(progn\n (foo))\n(bar)|" "ok") |
1071 | 1072 | "(progn\n (foo)\n (bar)|)")) |
1072 | | - (should (string= (lispy-with "(progn\n (foo))\n~(bar)|" (lispy-up-slurp)) |
| 1073 | + (should (string= (lispy-with "(progn\n (foo))\n~(bar)|" "ok") |
1073 | 1074 | "(progn\n (foo)\n ~(bar)|)")) |
1074 | | - (should (string= (lispy-with "(progn\n (foo))\n|(bar)~" (lispy-up-slurp)) |
| 1075 | + (should (string= (lispy-with "(progn\n (foo))\n|(bar)~" "ok") |
1075 | 1076 | "(progn\n (foo)\n |(bar)~)")) |
1076 | | - (should (string= (lispy-with "(progn\n (foo))\n|(bar)\n(baz)~" (lispy-up-slurp)) |
| 1077 | + (should (string= (lispy-with "(progn\n (foo))\n|(bar)\n(baz)~" "ok") |
1077 | 1078 | "(progn\n (foo)\n |(bar)\n (baz)~)")) |
1078 | | - (should (string= (lispy-with "(progn\n (foo))\n~(bar)\n(baz)|" (lispy-up-slurp)) |
| 1079 | + (should (string= (lispy-with "(progn\n (foo))\n~(bar)\n(baz)|" "ok") |
1079 | 1080 | "(progn\n (foo)\n ~(bar)\n (baz)|)"))) |
1080 | 1081 |
|
1081 | 1082 | (ert-deftest lispy-tab () |
@@ -1129,11 +1130,11 @@ Insert KEY if there's no command." |
1129 | 1130 | "(progn ,@(cdr re)|)"))) |
1130 | 1131 |
|
1131 | 1132 | (ert-deftest lispy-mark-car () |
1132 | | - (should (string= (lispy-with "|\"foo\"~" (lispy-mark-car)) |
| 1133 | + (should (string= (lispy-with "|\"foo\"~" "i") |
1133 | 1134 | "\"~foo|\"")) |
1134 | | - (should (string= (lispy-with "~'(\n foo)|" (lispy-mark-car)) |
| 1135 | + (should (string= (lispy-with "~'(\n foo)|" "i") |
1135 | 1136 | "'(\n ~foo|)")) |
1136 | | - (should (string= (lispy-with "|'(\n foo)~" (lispy-mark-car)) |
| 1137 | + (should (string= (lispy-with "|'(\n foo)~" "i") |
1137 | 1138 | "'(\n ~foo|)")) |
1138 | 1139 | (should (string= (lispy-with |
1139 | 1140 | "|(add-to-list 'auto-mode-alist '(\"\\\\.cache\\\\'\" . emacs-lisp-mode))" |
@@ -1196,7 +1197,7 @@ Insert KEY if there's no command." |
1196 | 1197 |
|
1197 | 1198 | (ert-deftest lispy-other-space () |
1198 | 1199 | (should (string= (lispy-with "(foo (bar (baz)|))" |
1199 | | - (lispy-other-space)) |
| 1200 | + "o ") |
1200 | 1201 | "(foo (bar (baz |)))"))) |
1201 | 1202 |
|
1202 | 1203 | (ert-deftest lispy-beginning-of-defun () |
|
0 commit comments