Skip to content

Commit 09f2776

Browse files
Document custom command action (#2921)
Co-authored-by: Pokey Rule <[email protected]>
1 parent 4f2a739 commit 09f2776

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

cursorless-talon-dev/src/cursorless_test.talon

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ test api extract decorated marks <user.cursorless_target>:
3232
test api alternate highlight nothing:
3333
user.private_cursorless_test_alternate_highlight_nothing()
3434

35-
test api parsed: user.cursorless_custom_command("chuck block")
35+
test api parsed: user.cursorless_x_custom_command("chuck block")
3636
test api parsed <user.cursorless_target>:
37-
user.cursorless_custom_command("chuck block <target>", cursorless_target)
37+
user.cursorless_x_custom_command("chuck block <target>", cursorless_target)
3838
test api parsed <user.cursorless_target> plus <user.cursorless_target>:
39-
user.cursorless_custom_command("bring block <target1> after <target2>", cursorless_target_1, cursorless_target_2)
39+
user.cursorless_x_custom_command("bring block <target1> after <target2>", cursorless_target_1, cursorless_target_2)

cursorless-talon/src/public_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def cursorless_create_destination(
2626

2727
@mod.action_class
2828
class CommandActions:
29-
def cursorless_custom_command(
29+
def cursorless_x_custom_command(
3030
content: str, # pyright: ignore [reportGeneralTypeIssues]
3131
arg1: Optional[Any] = None,
3232
arg2: Optional[Any] = None,

packages/cursorless-org-docs/src/docs/user/customization.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,40 @@ _You can disable the default Cursorless reformat command by prefixing the spoken
204204
<user.formatters> form <user.cursorless_target>:
205205
user.cursorless_reformat(cursorless_target, formatters)
206206
```
207+
208+
### Experimental custom command action
209+
210+
:::warning
211+
212+
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\_
213+
214+
:::
215+
216+
`user.cursorless_x_custom_command(command: string, *args)`
217+
218+
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.
219+
220+
- Utilizes default Cursorless spoken forms in the command string.
221+
- Optional target arguments can be interpolated in the command string. (see examples below)
222+
223+
#### Examples
224+
225+
In order to map `"scratch"` to perform `"chuck block"`:
226+
227+
```talon
228+
scratch: user.cursorless_x_custom_command("chuck block")
229+
```
230+
231+
To map `"scratch air"` => `"chuck block air"`
232+
233+
```talon
234+
scratch <user.cursorless_target>:
235+
user.cursorless_x_custom_command("chuck block <target>", cursorless_target)
236+
```
237+
238+
To map `"combine air plus bat"` => `"bring block air after bat"`
239+
240+
```talon
241+
combine <user.cursorless_target> plus <user.cursorless_target>:
242+
user.cursorless_x_custom_command("bring block <target1> after <target2>", cursorless_target_1, cursorless_target_2)
243+
```

0 commit comments

Comments
 (0)