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

Recursive macro guard without triggering an error #13870

Open
siers opened this issue Feb 3, 2021 · 0 comments
Open

Recursive macro guard without triggering an error #13870

siers opened this issue Feb 3, 2021 · 0 comments
Labels
enhancement feature request

Comments

@siers
Copy link

siers commented Feb 3, 2021

  • nvim --version: NVIM v0.4.4

When doing recursive macros, you need a guard condition to exit the macro repetition. I usually create a guard by either failing search or checking I can't move the cursor further because of the end of the line/file, which triggers an error and therefore stops the execution. This however, forbids nested recursive macro execution.

An example:
Macro №1: open a file at current line (from a file list) in a new tab, execute recursive macro №2, call macro №1.
Macro №2: search for a pattern (recursion guard condition, which causes an error), fix it, call macro №2.

Possible fix

A possible fix I can think of right now would be creating a normal mode prefix command that would stop the last macro's execution without triggering an error, but this would require a stack for the macro execution, which I'm not sure is present.

E.g. if mg would be the macro guard prefix, which would only stop last, not all macro execution, then mg/pattern would stop only the last macro upon a failing search.

Actual behaviour

Macro №1 never recurses, because the guard of macro №2 stops all execution.

Expected behaviour

Macro №1 recurses until its own guard triggers.

@siers siers added the enhancement feature request label Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature request
Projects
None yet
Development

No branches or pull requests

1 participant