AndreasArvidsson / andreas-talon

User scripts for Talon Voice
MIT License
73 stars 11 forks source link

`clippy_hint` capture uses nonstandard lists #12

Open pokey opened 4 months ago

pokey commented 4 months ago

https://github.com/AndreasArvidsson/andreas-talon/blob/24455da4e8bd5ed4ed13538530d0f2bc848451a6/plugins/clippy/clippy_targets.py#L31

pokey commented 4 months ago

Right now I'm running clippy-talon using a shallow clone of this repo:

git clone -n --depth=1 --filter=tree:0 'git@github.com:AndreasArvidsson/andreas-talon.git' clippy-talon
cd clippy-talon 
git sparse-checkout set plugins/clippy core/rpc_client
git checkout
AndreasArvidsson commented 4 months ago

This is going a have to change if I'm moving this into a separate repository. At long as its in my repository it's of course going to be based upon my lists and captures. You can just make a context specific override on that capture?

pokey commented 4 months ago

Yeah that's what I ended up doing. Pasting here for reference:

from talon import Context

ctx = Context()

@ctx.capture(rule="<user.number_key> | {user.letter} [{user.letter}]")
def clippy_hint(m) -> str:
    try:
        return str(m.number_key)
    except AttributeError:
        return "".join(m.letter_list)
AndreasArvidsson commented 4 months ago

Nice. Thank you :) I guess neither of those lists are mac specific though? Since it's already on a context it should win over the default module definition so you don't need to think about specificity.

pokey commented 4 months ago

oh really? I thought I had to have something on the context for it to win

AndreasArvidsson commented 4 months ago

Nope. Global context wins over global module.

pokey commented 4 months ago

Ok I edited the code snippet. Haven't tested it, but will take your word for it