diff --git a/cursorless-talon-dev/src/cursorless_test.talon b/cursorless-talon-dev/src/cursorless_test.talon index 339c642110..914f7d2aea 100644 --- a/cursorless-talon-dev/src/cursorless_test.talon +++ b/cursorless-talon-dev/src/cursorless_test.talon @@ -32,8 +32,8 @@ test api extract decorated marks : test api alternate highlight nothing: user.private_cursorless_test_alternate_highlight_nothing() -test api parsed: user.cursorless_custom_command("chuck block") +test api parsed: user.cursorless_x_custom_command("chuck block") test api parsed : - user.cursorless_custom_command("chuck block ", cursorless_target) + user.cursorless_x_custom_command("chuck block ", cursorless_target) test api parsed plus : - user.cursorless_custom_command("bring block after ", cursorless_target_1, cursorless_target_2) + user.cursorless_x_custom_command("bring block after ", cursorless_target_1, cursorless_target_2) diff --git a/cursorless-talon/src/public_api.py b/cursorless-talon/src/public_api.py index c332ad1cf3..cf5bc07838 100644 --- a/cursorless-talon/src/public_api.py +++ b/cursorless-talon/src/public_api.py @@ -26,7 +26,7 @@ def cursorless_create_destination( @mod.action_class class CommandActions: - def cursorless_custom_command( + def cursorless_x_custom_command( content: str, # pyright: ignore [reportGeneralTypeIssues] arg1: Optional[Any] = None, arg2: Optional[Any] = None, diff --git a/packages/cursorless-org-docs/src/docs/user/customization.md b/packages/cursorless-org-docs/src/docs/user/customization.md index 871c9cb734..ca9e1f088a 100644 --- a/packages/cursorless-org-docs/src/docs/user/customization.md +++ b/packages/cursorless-org-docs/src/docs/user/customization.md @@ -204,3 +204,40 @@ _You can disable the default Cursorless reformat command by prefixing the spoken form : user.cursorless_reformat(cursorless_target, formatters) ``` + +### Experimental custom command action + +:::warning + +This feature is experimental! Not as thoroughly tested as the rest of Cursorless and might change in the future. Early adopters should subscribe to this [discussion](https://github.com/cursorless-dev/cursorless/discussions/2942) to get updates about breaking changes\_ + +::: + +`user.cursorless_x_custom_command(command: string, *args)` + +Run a custom Cursorless command by parsing the specified command string. Supports a subset of the Cursorless grammar, with **default** spoken forms (not your custom spoken forms). See https://www.cursorless.org/custom-command-railroad to see the subset of our grammar that we support today. + +- Utilizes default Cursorless spoken forms in the command string. +- Optional target arguments can be interpolated in the command string. (see examples below) + +#### Examples + +In order to map `"scratch"` to perform `"chuck block"`: + +```talon +scratch: user.cursorless_x_custom_command("chuck block") +``` + +To map `"scratch air"` => `"chuck block air"` + +```talon +scratch : + user.cursorless_x_custom_command("chuck block ", cursorless_target) +``` + +To map `"combine air plus bat"` => `"bring block air after bat"` + +```talon +combine plus : + user.cursorless_x_custom_command("bring block after ", cursorless_target_1, cursorless_target_2) +```