From 00b660c91452717d9b522d696c3d5ec6293f80f0 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 2 Dec 2021 14:08:50 +0100 Subject: [PATCH 1/5] Added identity modifier. Added head tail modifier to csv --- src/modifiers/head_tail.py | 6 ++---- src/modifiers/identity.py | 14 ++++++++++++++ src/modifiers/modifiers.py | 8 ++++++++ src/primitive_target.py | 1 + 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/modifiers/identity.py diff --git a/src/modifiers/head_tail.py b/src/modifiers/head_tail.py index 159a7d6f..0c97ce8c 100644 --- a/src/modifiers/head_tail.py +++ b/src/modifiers/head_tail.py @@ -1,13 +1,11 @@ -from talon import Context, Module +from talon import Module mod = Module() -ctx = Context() mod.list("cursorless_head_tail", desc="Cursorless modifier for head or tail of line") -ctx.lists["self.cursorless_head_tail"] = {"head", "tail"} @mod.capture(rule="{user.cursorless_head_tail}") -def cursorless_head_tail(m) -> str: +def cursorless_head_tail(m) -> dict: return {"modifier": {"type": m.cursorless_head_tail}} diff --git a/src/modifiers/identity.py b/src/modifiers/identity.py new file mode 100644 index 00000000..21a1e4d4 --- /dev/null +++ b/src/modifiers/identity.py @@ -0,0 +1,14 @@ +from talon import Module + +mod = Module() + + +mod.list( + "cursorless_identity", + desc="Cursorless modifier for identity. Use to break inference.", +) + + +@mod.capture(rule="{user.cursorless_identity}") +def cursorless_head_tail(m) -> dict: + return {"modifier": {"type": "identity"}} diff --git a/src/modifiers/modifiers.py b/src/modifiers/modifiers.py index 1b474a75..2a820f02 100644 --- a/src/modifiers/modifiers.py +++ b/src/modifiers/modifiers.py @@ -8,12 +8,20 @@ "bound": "excludeInterior", } +head_tail = { + "head": "head", + "tail": "tail", +} +identity = {"just": "identity"} + def on_ready(): init_csv_and_watch_changes( "modifiers", { "delimiter_inclusion": delimiter_inclusions, + "head_tail": head_tail, + "identity": identity, }, ) diff --git a/src/primitive_target.py b/src/primitive_target.py index a436e6c2..8cd4007e 100644 --- a/src/primitive_target.py +++ b/src/primitive_target.py @@ -21,6 +21,7 @@ "", # funk, state, class "", # first past second word "", # matching/pair [curly, round] + "", # just # "", # matching ] From 5d3540b1f3aacfde9c4a2336b69b52a520794eaa Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 2 Dec 2021 14:40:48 +0100 Subject: [PATCH 2/5] Update src/modifiers/identity.py Co-authored-by: Pokey Rule --- src/modifiers/identity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modifiers/identity.py b/src/modifiers/identity.py index 21a1e4d4..eab47a39 100644 --- a/src/modifiers/identity.py +++ b/src/modifiers/identity.py @@ -10,5 +10,5 @@ @mod.capture(rule="{user.cursorless_identity}") -def cursorless_head_tail(m) -> dict: +def cursorless_identity(m) -> dict: return {"modifier": {"type": "identity"}} From 411a1ec0ca81bf56b668dc3b172e9c8680a19a36 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 2 Dec 2021 14:52:28 +0100 Subject: [PATCH 3/5] Update src/modifiers/modifiers.py Co-authored-by: Pokey Rule --- src/modifiers/modifiers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modifiers/modifiers.py b/src/modifiers/modifiers.py index 2a820f02..a724e72e 100644 --- a/src/modifiers/modifiers.py +++ b/src/modifiers/modifiers.py @@ -9,8 +9,8 @@ } head_tail = { - "head": "head", - "tail": "tail", + "head": "extendThroughStartOf", + "tail": "extendThroughEndOf", } identity = {"just": "identity"} From 53f5b6c86e4e03654cee904ea9679a186c94e9e3 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 2 Dec 2021 15:04:07 +0100 Subject: [PATCH 4/5] Changed identifier on head tail --- src/modifiers/head_tail.py | 22 ++++++++++++++++++++-- src/modifiers/modifiers.py | 6 +----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/modifiers/head_tail.py b/src/modifiers/head_tail.py index 0c97ce8c..37d14812 100644 --- a/src/modifiers/head_tail.py +++ b/src/modifiers/head_tail.py @@ -1,11 +1,29 @@ from talon import Module +from dataclasses import dataclass mod = Module() +mod.list("cursorless_head_tail", desc="Cursorless modifier for head or tail of line") -mod.list("cursorless_head_tail", desc="Cursorless modifier for head or tail of line") +@dataclass +class HeadTail: + defaultSpokenForm: str + cursorlessIdentifier: str + type: str + + +head_tail_list = [ + HeadTail("head", "extendThroughStartOf", "head"), + HeadTail("tail", "extendThroughEndOf", "tail"), +] +head_tail_map = {i.cursorlessIdentifier: i.type for i in head_tail_list} +head_tail = {i.defaultSpokenForm: i.cursorlessIdentifier for i in head_tail_list} @mod.capture(rule="{user.cursorless_head_tail}") def cursorless_head_tail(m) -> dict: - return {"modifier": {"type": m.cursorless_head_tail}} + return { + "modifier": { + "type": head_tail_map[m.cursorless_head_tail], + } + } diff --git a/src/modifiers/modifiers.py b/src/modifiers/modifiers.py index a724e72e..48e57c26 100644 --- a/src/modifiers/modifiers.py +++ b/src/modifiers/modifiers.py @@ -1,5 +1,6 @@ from talon import app from ..csv_overrides import init_csv_and_watch_changes +from .head_tail import head_tail # NOTE: Please do not change these dicts. Use the CSVs for customization. # See https://github.com/pokey/cursorless-talon/blob/main/docs/customization.md @@ -7,11 +8,6 @@ "inside": "interiorOnly", "bound": "excludeInterior", } - -head_tail = { - "head": "extendThroughStartOf", - "tail": "extendThroughEndOf", -} identity = {"just": "identity"} From 5058e7f49ebb6bd7dc323e6b1046b88f47bc58bb Mon Sep 17 00:00:00 2001 From: Pokey Rule Date: Thu, 2 Dec 2021 17:55:31 +0000 Subject: [PATCH 5/5] Update src/modifiers/identity.py --- src/modifiers/identity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modifiers/identity.py b/src/modifiers/identity.py index eab47a39..44d2fcaa 100644 --- a/src/modifiers/identity.py +++ b/src/modifiers/identity.py @@ -5,7 +5,7 @@ mod.list( "cursorless_identity", - desc="Cursorless modifier for identity. Use to break inference.", + desc="Cursorless modifier for identity. Use to break inference chain.", )