Skip to content

Commit 4a92852

Browse files
authored
Add emacs-mcx.enableDigitArgument config (#1256)
* Add emacs-mcx.enableDigitArgument config * Update README.md and CHANGELOG.md * Fix
1 parent e9aee2d commit 4a92852

File tree

4 files changed

+104
-82
lines changed

4 files changed

+104
-82
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to the "emacs-mcx" extension will be documented in this file.
33

44
## [Unreleased]
5+
6+
### Add
7+
- `emacs-mcx.enableDigitArgument` config, #1256.
8+
59
## [0.40.1] - 2022-03-20
610
### Fix
711
- Release process, #1254.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ Note that this config makes use of VSCode API's `type` command under the hood an
102102
* If you are using IME, text input may sometimes fail.
103103
* If another extension that also uses the `type` command is installed, an error occurs (See https://github.com/Microsoft/vscode/issues/13441).
104104

105+
### `emacs-mcx.enableDigitArgument`
106+
Indicates whether `M-<digit>` (the `emacs-mcx.digitArgument` command) is enabled.
107+
Set `false` when `M-<digit>` conflicts with some other necessary commands. See https://github.com/whitphx/vscode-emacs-mcx/issues/1208 for the background.
108+
105109
### `emacs-mcx.debug.*`
106110
Configurations for debugging.
107111

keybinding-generator/generate-keybindings.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ export function generateKeybindings(src: KeyBindingSource): KeyBinding[] {
143143
return keybindings;
144144
}
145145

146+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
146147
export function isKeyBindingSource(maybeSrc: { [key: string]: any }): maybeSrc is KeyBindingSource {
147148
// Check for .key
148149
if (typeof maybeSrc.key !== "undefined" && typeof maybeSrc.key !== "string") {
@@ -189,17 +190,25 @@ export function generateKeybindingsForPrefixArgument(): KeyBinding[] {
189190
for (let num = 0; num <= 9; ++num) {
190191
keybindings.push(
191192
...generateKeybindings({
192-
keys: [num.toString(), `meta+${num.toString()}`],
193+
key: num.toString(),
193194
command: "emacs-mcx.subsequentArgumentDigit",
194195
when: "emacs-mcx.acceptingArgument && editorTextFocus",
195196
args: [num],
196197
})
197198
);
199+
keybindings.push(
200+
...generateKeybindings({
201+
key: `meta+${num.toString()}`,
202+
command: "emacs-mcx.subsequentArgumentDigit",
203+
when: "emacs-mcx.acceptingArgument && editorTextFocus && config.emacs-mcx.enableDigitArgument",
204+
args: [num],
205+
})
206+
);
198207
keybindings.push(
199208
...generateKeybindings({
200209
key: `meta+${num.toString()}`,
201210
command: "emacs-mcx.digitArgument",
202-
when: "!emacs-mcx.acceptingArgument && editorTextFocus",
211+
when: "!emacs-mcx.acceptingArgument && editorTextFocus && config.emacs-mcx.enableDigitArgument",
203212
args: [num],
204213
})
205214
);

0 commit comments

Comments
 (0)