Skip to content

Latest commit

 

History

History
80 lines (59 loc) · 3.01 KB

DEVELOPMENT.md

File metadata and controls

80 lines (59 loc) · 3.01 KB

Awesome Emacs Keymap

Development

Unit test, linter, and CI

This repository has introduced linter (ESlint), code formatter (Prettier), and unit testing.

Linter

To run linter,

$ yarn lint

Formatter

To apply formatter,

$ yarn prettier

Unit tests

To run unit tests, open VSCode's debug sidebar and run "Extension Tests".

Hint: You can also launch a new VSCode window with the extension under development by "Launch Extension".

See also https://code.visualstudio.com/docs/editor/debugging

CI

CI runs coding style checks and unit tests (See also azure-pipelines.yml).

Make sure that CI has passed all coding style checks and unit tests before requesting PR reviews.

Keybindings generation

Keybindings of a VSCode extension must be defined in its contributes.keybindings section in package.json as described in the doc, but you MUST NOT edit it directly in case of this extension.

Instead, to change the keybindings, you have to edit keybindings.json and run yarn gen-keys to generate resultant keybinding definitions and update package.json with them.

After that, you have to commit the auto-updated package.json in addition to keybindings.json. Please also edit the keybindings list in README.md.

In keybindings.json, you can use some extended syntax described below.

keys, whens

You can define multiple key combinations and/or when conditions for one command. It's useful to define keybindings like below.

{
  "keys": ["right", "ctrl+f"],
  "command": "emacs-mcx.forwardChar",
  "whens": ["editorTextFocus", "terminalFocus"]
}

meta key

You can use "meta" key in key and keys fields. It is converted basically to "alt" key, in addition, "cmd" and "escape" keys. Those "cmd" and "escape" keys are generated with "when": "config.emacs-mcx.useMetaPrefixMacCmd" and "when": "config.emacs-mcx.useMetaPrefixEscape" conditions respectively, that enables users to switch the key to use as a meta key by the config.

Comments

You can write comments in keybindings.json.

How to add a new command

First you have to create a command class. One command is implemented as one class extending EmacsCommand class. See src/commands/*.ts.

After a new command class is implemented, it must be registered to commandRegistry in EmacsEmulator class, which is the central controller of this extension. See src/emulator.ts.

Then, you have to register a new command exposed by the extension to trigger the emulator's command registered above. See src/extension.ts.

Finally, bind the exposed command to key strokes. It's typically done by editing package.json though, it's incorrect in this extension. Edit keybindings.json and run yarn gen-keys instead as described above.