Skip to content

Commit eee6eea

Browse files
Support "bring" in custom api (#1226)
Enables things like: ```talon foo bar <user.cursorless_target>: some.stuff() user.cursorless_command("replaceWithTarget", cursorless_target) other.stuff() ``` ## Checklist - [ ] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [ ] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [ ] I have not broken the cheatsheet Co-authored-by: Andreas Arvidsson <[email protected]>
1 parent 83ca104 commit eee6eea

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

cursorless-talon/src/actions/actions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from talon import Module, actions, app
22

33
from ..csv_overrides import init_csv_and_watch_changes
4+
from ..primitive_target import IMPLICIT_TARGET
45
from .actions_callback import callback_action_defaults, callback_action_map
56
from .actions_custom import custom_action_defaults
67
from .actions_simple import (
@@ -43,6 +44,10 @@ def cursorless_command(action_id: str, target: dict):
4344
actions.user.cursorless_single_target_command_no_wait(action_id, target)
4445
if action_id in no_wait_actions_post_sleep:
4546
actions.sleep(no_wait_actions_post_sleep[action_id])
47+
elif action_id in ["replaceWithTarget", "moveToTarget"]:
48+
actions.user.cursorless_multiple_target_command(
49+
action_id, [target, IMPLICIT_TARGET.copy()]
50+
)
4651
else:
4752
return actions.user.cursorless_single_target_command(action_id, target)
4853

docs/user/customization.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,11 @@ Cursorless exposes a couple talon actions and captures that you can use to defin
111111

112112
### Public Talon actions
113113

114-
- `user.cursorless_command(action_id: str, target: cursorless_target)`
114+
- `user.cursorless_command(action_id: str, target: cursorless_target)`:
115115
Perform a Cursorless command on the given target
116-
eg: `user.cursorless_command("setSelection", cursorless_target)`
117-
- `user.cursorless_ide_command(command_id: str, target: cursorless_target)`
116+
eg: `user.cursorless_command("setSelection", cursorless_target)`.
117+
Note that for `"bring"` (`replaceWithTarget`), `cursorless_target` will be the source of the bring and the destination will be the current selection(s), as if you had said `"bring <target>"`
118+
- `user.cursorless_ide_command(command_id: str, target: cursorless_target)`:
118119
Performs a built-in IDE command on the given target
119120
eg: `user.cursorless_ide_command("editor.action.addCommentLine", cursorless_target)`
120121

0 commit comments

Comments
 (0)