Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added identity modifier. Added head tail modifier to csv #115

Merged
merged 5 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions src/modifiers/head_tail.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
from talon import Context, Module
from talon import Module
from dataclasses import dataclass

mod = Module()
ctx = Context()
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")
ctx.lists["self.cursorless_head_tail"] = {"head", "tail"}
@dataclass
class HeadTail:
defaultSpokenForm: str
cursorlessIdentifier: str
type: str


head_tail_list = [
HeadTail("head", "extendThroughStartOf", "head"),
HeadTail("tail", "extendThroughEndOf", "tail"),
Comment on lines +16 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Yeah probably path of least resistance for now rather than having to mess around extension-side

]
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) -> str:
return {"modifier": {"type": m.cursorless_head_tail}}
def cursorless_head_tail(m) -> dict:
return {
"modifier": {
"type": head_tail_map[m.cursorless_head_tail],
}
}
14 changes: 14 additions & 0 deletions src/modifiers/identity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from talon import Module

mod = Module()


mod.list(
"cursorless_identity",
desc="Cursorless modifier for identity. Use to break inference.",
pokey marked this conversation as resolved.
Show resolved Hide resolved
)


@mod.capture(rule="{user.cursorless_identity}")
def cursorless_identity(m) -> dict:
return {"modifier": {"type": "identity"}}
4 changes: 4 additions & 0 deletions src/modifiers/modifiers.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
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
delimiter_inclusions = {
"inside": "interiorOnly",
"bound": "excludeInterior",
}
identity = {"just": "identity"}


def on_ready():
init_csv_and_watch_changes(
"modifiers",
{
"delimiter_inclusion": delimiter_inclusions,
"head_tail": head_tail,
"identity": identity,
},
)

Expand Down
1 change: 1 addition & 0 deletions src/primitive_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"<user.cursorless_containing_scope>", # funk, state, class
"<user.cursorless_subtoken_scope>", # first past second word
"<user.cursorless_surrounding_pair>", # matching/pair [curly, round]
"<user.cursorless_identity>", # just
# "<user.cursorless_matching_paired_delimiter>", # matching
]

Expand Down