Skip to content

Commit 6991b59

Browse files
committed
git subrepo pull --remote=file:///Users/pokey/src/cursorless-talon-development --branch=limited-after cursorless-talon
subrepo: subdir: "cursorless-talon" merged: "21c27bb2" upstream: origin: "file:///Users/pokey/src/cursorless-talon-development" branch: "limited-after" commit: "21c27bb2" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596"
1 parent 2bbec6d commit 6991b59

File tree

11 files changed

+86
-25
lines changed

11 files changed

+86
-25
lines changed

cursorless-talon/src/actions/actions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from talon import Module, app, actions
22
from ..csv_overrides import init_csv_and_watch_changes
3-
from .actions_simple import simple_action_defaults
3+
from .actions_simple import simple_action_defaults, positional_action_defaults
44
from .actions_callback import callback_action_defaults, callback_action_map
55
from .actions_makeshift import (
66
makeshift_action_defaults,
@@ -81,6 +81,7 @@ def vscode_command_no_wait(command_id: str, target: dict, command_options: dict
8181

8282
default_values = {
8383
"simple_action": simple_action_defaults,
84+
"positional_action": positional_action_defaults,
8485
"callback_action": callback_action_defaults,
8586
"makeshift_action": makeshift_action_defaults,
8687
"custom_action": custom_action_defaults,

cursorless-talon/src/actions/actions_simple.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,18 @@
3434
"unfold": "unfoldRegion",
3535
}
3636

37+
# NOTE: Please do not change these dicts. Use the CSVs for customization.
38+
# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md
39+
positional_action_defaults = {
40+
"paste": "pasteFromClipboard",
41+
}
42+
3743
mod = Module()
3844
mod.list(
3945
"cursorless_simple_action",
4046
desc="Supported simple actions for cursorless navigation",
4147
)
48+
mod.list(
49+
"cursorless_positional_action",
50+
desc="Supported actions for cursorless that expect a positional target",
51+
)

cursorless-talon/src/actions/call.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55

66

77
def run_call_action(target: dict):
8-
targets = [target, IMPLICIT_TARGET]
8+
targets = [target, IMPLICIT_TARGET.copy()]
99
actions.user.cursorless_multiple_target_command("callAsFunction", targets)

cursorless-talon/src/actions/move_bring.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,21 @@
33

44
mod = Module()
55
mod.list(
6-
"cursorless_source_destination_connective",
6+
"cursorless_positional_connective",
77
desc="The connective used to separate source and destination targets",
88
)
99

1010

1111
mod.list("cursorless_move_bring_action", desc="Cursorless move or bring actions")
1212

1313

14-
@mod.capture(
15-
rule=(
16-
"<user.cursorless_target> [{user.cursorless_source_destination_connective} <user.cursorless_target>]"
17-
)
18-
)
14+
@mod.capture(rule=("<user.cursorless_target> [<user.cursorless_positional_target>]"))
1915
def cursorless_move_bring_targets(m) -> list[dict]:
20-
target_list = m.cursorless_target_list
16+
target_list = [m.cursorless_target]
2117

22-
if len(target_list) == 1:
23-
target_list = target_list + [IMPLICIT_TARGET]
18+
try:
19+
target_list += [m.cursorless_positional_target]
20+
except AttributeError:
21+
target_list += [IMPLICIT_TARGET.copy()]
2422

25-
return target_list
23+
return target_list

cursorless-talon/src/cheatsheet/sections/actions.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def get_actions():
2727
}
2828

2929
swap_connective = list(get_raw_list("swap_connective").keys())[0]
30-
source_destination_connective = list(
31-
get_raw_list("source_destination_connective").keys()
32-
)[0]
30+
positional_connectives = {
31+
value: key for key, value in get_raw_list("positional_connective").items()
32+
}
3333

3434
make_dict_readable(
3535
simple_actions,
@@ -39,10 +39,14 @@ def get_actions():
3939
)
4040
return {
4141
**simple_actions,
42-
f"{complex_actions['replaceWithTarget']} <T1> {source_destination_connective} <T2>": "Replace T2 with T1",
43-
f"{complex_actions['replaceWithTarget']} <T>": "Replace S with T",
44-
f"{complex_actions['moveToTarget']} <T1> {source_destination_connective} <T2>": "Move T1 to T2",
45-
f"{complex_actions['moveToTarget']} <T>": "Move T to S",
42+
f"{complex_actions['replaceWithTarget']} T1 {positional_connectives['contentConnective']} T2": "Replace T2 with T1",
43+
f"{complex_actions['replaceWithTarget']} T1 {positional_connectives['afterConnective']} T2": "Copy T2 after T1",
44+
f"{complex_actions['replaceWithTarget']} T1 {positional_connectives['beforeConnective']} T2": "Copy T2 before T1",
45+
f"{complex_actions['replaceWithTarget']} T": "Replace S with T",
46+
f"{complex_actions['moveToTarget']} T1 {positional_connectives['contentConnective']} T2": "Move T1 to T2",
47+
f"{complex_actions['moveToTarget']} T1 {positional_connectives['afterConnective']} T2": "Move T1 after T2",
48+
f"{complex_actions['moveToTarget']} T1 {positional_connectives['beforeConnective']} T2": "Move T1 before T2",
49+
f"{complex_actions['moveToTarget']} T": "Move T to S",
4650
f"{complex_actions['swapTargets']} <T1> {swap_connective} <T2>": "Swap T1 with T2",
4751
f"{complex_actions['swapTargets']} <T>": "Swap S with T",
4852
f"{complex_actions['applyFormatter']} <F> at <T>": "Reformat T as F",

cursorless-talon/src/command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def cursorless_this_command(
5454
):
5555
"""Execute cursorless command, passing `this` as single target"""
5656
actions.user.cursorless_multiple_target_command(
57-
action, [IMPLICIT_TARGET], arg1, arg2, arg3
57+
action, [IMPLICIT_TARGET.copy()], arg1, arg2, arg3
5858
)
5959

6060
def cursorless_single_target_command_with_arg_list(

cursorless-talon/src/connective.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
"until": "rangeExcludingEnd",
1111
}
1212

13+
# NOTE: Please do not change these dicts. Use the CSVs for customization.
14+
# See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md
15+
positional_connectives = {
16+
"after": "afterConnective",
17+
"before": "beforeConnective",
18+
"to": "contentConnective",
19+
}
20+
1321
default_range_connective = "rangeInclusive"
1422

1523

@@ -20,7 +28,7 @@ def on_ready():
2028
"range_connective": range_connectives,
2129
"list_connective": {"and": "listConnective"},
2230
"swap_connective": {"with": "swapConnective"},
23-
"source_destination_connective": {"to": "sourceDestinationConnective"},
31+
"positional_connective": positional_connectives,
2432
},
2533
)
2634

cursorless-talon/src/cursorless-snippets.talon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ tag: user.cursorless_experimental_snippets
55
{user.cursorless_insert_snippet_action} <user.cursorless_insertion_snippet>:
66
user.cursorless_this_command(cursorless_insert_snippet_action, cursorless_insertion_snippet)
77

8-
{user.cursorless_insert_snippet_action} <user.cursorless_insertion_snippet> <user.cursorless_target>:
9-
user.cursorless_single_target_command(cursorless_insert_snippet_action, cursorless_target, cursorless_insertion_snippet)
8+
{user.cursorless_insert_snippet_action} <user.cursorless_insertion_snippet> <user.cursorless_positional_target>:
9+
user.cursorless_single_target_command(cursorless_insert_snippet_action, cursorless_positional_target, cursorless_insertion_snippet)
1010

1111
{user.cursorless_insert_snippet_action} {user.cursorless_insertion_snippet_single_phrase} <user.text> [halt]:
1212
user.cursorless_insert_snippet_with_phrase(cursorless_insert_snippet_action, cursorless_insertion_snippet_single_phrase, text)

cursorless-talon/src/cursorless.talon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ app: vscode
44
<user.cursorless_action_or_vscode_command> <user.cursorless_target>:
55
user.cursorless_action_or_vscode_command(cursorless_action_or_vscode_command, cursorless_target)
66

7+
{user.cursorless_positional_action} <user.cursorless_positional_target>:
8+
user.cursorless_single_target_command(cursorless_positional_action, cursorless_positional_target)
9+
710
{user.cursorless_swap_action} <user.cursorless_swap_targets>:
811
user.cursorless_multiple_target_command(cursorless_swap_action, cursorless_swap_targets)
912

cursorless-talon/src/modifiers/position.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66

77
positions = {
8-
"after": {"position": "after"},
9-
"before": {"position": "before"},
108
"start of": {"position": "before", "insideOutsideType": "inside"},
119
"end of": {"position": "after", "insideOutsideType": "inside"},
1210
# Disabled for now because "below" can misrecognize with "blue" and we may move away from allowing positional modifiers in arbitrary places anyway
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from talon import Module
2+
3+
mod = Module()
4+
5+
6+
@mod.capture(rule=("{user.cursorless_positional_connective} <user.cursorless_target>"))
7+
def cursorless_positional_target(m) -> list[dict]:
8+
return process_positional_connective(
9+
m.cursorless_positional_connective, m.cursorless_target
10+
)
11+
12+
13+
def process_positional_connective(cursorless_positional_connective: str, target: dict):
14+
if cursorless_positional_connective == "afterConnective":
15+
return update_first_primitive_target(target, {"position": "after"})
16+
elif cursorless_positional_connective == "beforeConnective":
17+
return update_first_primitive_target(target, {"position": "before"})
18+
19+
return target
20+
21+
22+
def update_first_primitive_target(target: dict, fields: dict):
23+
if target["type"] == "primitive":
24+
return {**target, **fields}
25+
elif target["type"] == "range":
26+
return {
27+
**target,
28+
"start": update_first_primitive_target(target["start"], fields),
29+
}
30+
else:
31+
elements = target["elements"]
32+
33+
return {
34+
**target,
35+
"elements": [
36+
update_first_primitive_target(elements[0], fields),
37+
*elements[1:],
38+
],
39+
}

0 commit comments

Comments
 (0)