Skip to content

Commit

Permalink
Extending custom grammar (#2436)
Browse files Browse the repository at this point in the history
Extending custom grammar with actions

#492

## 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)
- [/] I have not broken the cheatsheet

---------

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Pokey Rule <[email protected]>
  • Loading branch information
3 people authored Jun 21, 2024
1 parent b75aee5 commit a078b42
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/public_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from talon import Module
from typing import Any, Optional

from talon import Module, actions

from .targets.target_types import (
CursorlessDestination,
Expand All @@ -20,3 +22,21 @@ def cursorless_create_destination(
) -> CursorlessDestination:
"""Cursorless: Create destination from target"""
return PrimitiveDestination(insertion_mode, target)


@mod.action_class
class CommandActions:
def cursorless_custom_command(
content: str, # pyright: ignore [reportGeneralTypeIssues]
arg1: Optional[Any] = None,
arg2: Optional[Any] = None,
arg3: Optional[Any] = None,
):
"""Cursorless: Run custom parsed command"""
actions.user.private_cursorless_command_and_wait(
{
"name": "parsed",
"content": content,
"arguments": [arg for arg in [arg1, arg2, arg3] if arg is not None],
}
)

0 comments on commit a078b42

Please sign in to comment.