cursorless-dev / cursorless

Don't let the cursor slow you down
https://www.cursorless.org/
MIT License
1.13k stars 79 forks source link

Feature request: A keyword similar to `its` that refers to an instance #1603

Open MartinRykfors opened 1 year ago

MartinRykfors commented 1 year ago

https://talonvoice.slack.com/archives/C026KPTJE6T/p1687163697513309

Message from slack reproduced here (some formatting issues):

I am trying to do this (^ being the hat I am targeting)


# comparison operators
(op | ^is) equal: user.code_operator_equal() 
(op | is) not equal: user.code_operator_not_equal()
(op | is) (greater | more): user.code_operator_greater_than()
(op | is) (less | below) [than]: user.code_operator_less_than()
(op | is) greater [than] or equal: user.code_operator_greater_than_or_equal_to()
(op | is) less [than] or equal: user.code_operator_less_than_or_equal_to()

> I want to replace every `(op | is)` with just `is`. If I had only one instance to change this way, I would say bring `ink to its round`. I am trying to do this with instances. `from block ink bring every instance ink to its round` However, this seems to bring every is to replace the first `(op | is)` so the result is 
```is is is is ... equal: user.code_operator_equal()```
> It seems like `its` refers to the original target. Can I say something different to make `its` behave as if it is scoped to the instance?

It would be nice to have a keyword like `its` that refers to the instance being operated on instead of referring to the last used target. This could enable some macro-like editing in one go, for instance `swap every instance air with their second next token`
pokey commented 1 year ago

Yeah I'm actually collecting examples for a more powerful command that allows you to do things like this. There are a few ways to do it. I'll file an issue with examples and possible implementations soon. Thanks for filing

pokey commented 11 months ago

see also https://github.com/cursorless-dev/cursorless/issues/1952

pokey commented 11 months ago

see https://github.com/cursorless-dev/cursorless/issues/1952#issuecomment-1772994742 for implementation proposal; should be fairly straightforward I think