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

Experimental private Cursorless Talon api #1784

Merged
merged 16 commits into from
Dec 19, 2023

Conversation

pokey
Copy link
Member

@pokey pokey commented Aug 14, 2023

Checklist

  • I have added tests
  • [-] I have updated the docs and cheatsheet
  • I have not broken the cheatsheet

@pokey pokey added the to discuss Plan to discuss at meet-up label Aug 14, 2023

@mod.action_class
class MiscActions:
def cursorless_v1_extract_decorated_marks(capture: Any) -> list[dict]:
Copy link
Member Author

@pokey pokey Aug 14, 2023

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

@pokey
Copy link
Member Author

pokey commented Aug 16, 2023

update from meet-up:

  • Keep this "internal" for now as we don't want to commit to maintaining this expansive of an api yet

@pokey pokey removed the to discuss Plan to discuss at meet-up label Aug 24, 2023
@pokey
Copy link
Member Author

pokey commented Dec 18, 2023

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

@pokey pokey marked this pull request as ready for review December 18, 2023 14:42
@pokey pokey changed the title Start expanding Cursorless Talon api Experimental prviate Cursorless Talon api Dec 18, 2023
@pokey pokey changed the title Experimental prviate Cursorless Talon api Experimental private Cursorless Talon api Dec 18, 2023
@pokey
Copy link
Member Author

pokey commented Dec 18, 2023

one sec I'll add a couple quick talon api tests so this doesn't break

@pokey pokey marked this pull request as draft December 18, 2023 14:44
@pokey pokey marked this pull request as ready for review December 18, 2023 15:28
@pokey
Copy link
Member Author

pokey commented Dec 18, 2023

ok tests added; ready for review

@mod.action_class
class ActionActions:
def cursorless_private_action_highlight(
target: CursorlessTarget, highlightId: Optional[str] = None
Copy link
Member

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.

Copy link
Member Author

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):
Copy link
Member

Choose a reason for hiding this comment

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

This syntax is interesting.

Copy link
Member Author

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

Copy link
Member

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.

Copy link
Member Author

@pokey pokey Dec 19, 2023

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

Copy link
Member

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.

Copy link
Member Author

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 😅

@pokey pokey added this pull request to the merge queue Dec 19, 2023
Merged via the queue into main with commit 297ec43 Dec 19, 2023
14 checks passed
@pokey pokey deleted the pokey/start-expanding-cursorless-talon-api branch December 19, 2023 14:33
cursorless-bot pushed a commit that referenced this pull request Dec 19, 2023
- 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>
thetomcraig-aya pushed a commit to thetomcraig/cursorless that referenced this pull request Mar 27, 2024
- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants