-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
Experimental private Cursorless Talon api #1784
Conversation
|
||
@mod.action_class | ||
class MiscActions: | ||
def cursorless_v1_extract_decorated_marks(capture: Any) -> list[dict]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently used as follows: https://github.com/pokey/wax_talon/blob/4bd7d9b9112a4172d4fc46fe5644e33b8b1340b7/recorders/cursorless_recorder.py#L151-L159. The parsed
argument there is expected to be list(j["parsed"])
, where j
is the argument to an on_phrase
callback. I wonder if we want to expose something that operates directly on the phrase object rather than requiring the pre-processing 🤔. This function does work on the output of any of our spoken form captures, so I think may still be a reasonable api
update from meet-up:
|
ok @AndreasArvidsson as discussed I made this private for now so that I can use it for wax_talon without needing to expose it to the world. Ready for review |
one sec I'll add a couple quick talon api tests so this doesn't break |
ok tests added; ready for review |
@mod.action_class | ||
class ActionActions: | ||
def cursorless_private_action_highlight( | ||
target: CursorlessTarget, highlightId: Optional[str] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you actually use the highlight id? Otherwise the highlight action should just work with our existing public api.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I do
|
||
def extract_decorated_marks(capture: Any) -> list[Any]: | ||
match capture: | ||
case PrimitiveTarget(mark=mark): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This syntax is interesting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah kinda nice I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how to read this. I totally follow the examples case MyClass(value=5)
checks if the instance is of the correct type and the value field is the correct value. mark=mark
I'm unsure how to interpret.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It creates a local variable mark
bound to whatever mark
was in that dataclass. It's analogous to const {x: x} = foo
, where it constructs a local variable x
bound to whatever was in the x
field of foo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that syntax can be made for both comparisons and assignments. hmm. Sometimes python is a little bit to clever for my taste.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha yeah I hadn't thought about that you can use it with constant. Yes maybe a bit clever 😅
- Private experimental api; one version of #492 - Currently used by [`wax_talon`](https://github.com/pokey/wax_talon); see pokey/wax_talon@4bd7d9b for example usage - Depends on #1880 for Python 3.10 `match` statements ## Checklist - [x] 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) - [x] I have not broken the cheatsheet --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
- Private experimental api; one version of cursorless-dev#492 - Currently used by [`wax_talon`](https://github.com/pokey/wax_talon); see pokey/wax_talon@4bd7d9b for example usage - Depends on cursorless-dev#1880 for Python 3.10 `match` statements ## Checklist - [x] 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) - [x] I have not broken the cheatsheet --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
wax_talon
; see pokey/wax_talon@4bd7d9b for example usagematch
statementsChecklist