Skip to content

Add support to repeat commands #378

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

Open
AndreasArvidsson opened this issue Dec 11, 2021 · 9 comments
Open

Add support to repeat commands #378

AndreasArvidsson opened this issue Dec 11, 2021 · 9 comments
Labels
enhancement New feature or request

Comments

@AndreasArvidsson
Copy link
Member

AndreasArvidsson commented Dec 11, 2021

Tokens and selection are treated on a text level
take air three times => Selects the token air and the next two instances of the same text
clear this twice => Clears the current selection and the next instance of the same text
take first word twice => Selects the first sub word and the next instance of the same text
take air past bat twice => Selects the range and the next instance of the same text

More complex scope and selection types are treated by order
take line air twice => Selects the line containing air and the next line below
take funk twice => Selects the current function and the next one below

To make this implementation feasible we probably need the new object oriented targets.

In the meantime there is an "ad hoc" solution to try:
https://github.com/AndreasArvidsson/andreas-talon/blob/master/apps/vscode/vscode_take_word.talon

Ponderings:

  • Should we have a grammar to go in the opposite direction? take air last three times
  • Should be try to align repeater commands with the user via a capture function or a csv file?
@AndreasArvidsson
Copy link
Member Author

AndreasArvidsson commented Dec 11, 2021

Related to #30
Related to #29

@pokey
Copy link
Member

pokey commented Dec 12, 2021

Ok so one thought I had was that it may be action-dependant rather than just scope type dependant. For example, if a user implements the Paredit "slurp" command via custom commands (or if we implement it in the future) if they say "slurp air three times", the logical thing is that it slurps the next three forms, but I don't think there's any scope type information that we could use to infer that as the desired behaviour

@AndreasArvidsson
Copy link
Member Author

That one is a bit harder. But I don't think that the reason it won't work for exactly everything is a good reason to not implemented it?

@pokey
Copy link
Member

pokey commented Dec 12, 2021

Well the problem is that it will shadow that command. It just feels like an indication that we don't yet fully understand this one. We both landed on the notion that it is action-independent, but this counterexample tells me it needs some more thought

Here's another example: "pour line three times". According to the logic we have here, that would create a newline after each of the next three lines. But again that isn't what I'd expect. I'd expect three new lines below the current line.

@pokey
Copy link
Member

pokey commented Dec 12, 2021

So I think fundamentally any solution here would need to look at both the action and the targets

@pokey
Copy link
Member

pokey commented Dec 12, 2021

What could make sense is to introduce a few target-action specific implementations, and fall back to basic repeater otherwise

@AndreasArvidsson
Copy link
Member Author

I have no objections that the implementation needs to be aware of the action. Everything to make it as intuitive and fluent as possible.

@pokey
Copy link
Member

pokey commented Dec 12, 2021

Also worth thinking about how much this stuff overlaps with the "take next two funk" grammar, because I think that grammar is fairly unambiguous so may be preferable in certain situations

@AndreasArvidsson
Copy link
Member Author

Yes in many cases it does the same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants