1. Frank Fischer
  2. evil
Issue #10 resolved

Problem with recursive macros

created an issue

Trying to call a macro from within itself yields No previous macro, and then it's impossible to enter macro recording again - Emacs will just state "not defining macro".

To reproduce, make a buffer like so:




Then execute: qqqqqdwj@qq@q: That should clear register q, (start record to q, stop, start record to q again) delete the first word, move a line down, attempt to call the for-now-empty q macro (this is where it fails) then end recording and call q. Expected behavior is that all lines should have their first word removed.

Comments (7)

  1. Vegard Øye

    The "Not defining macro" bug has been fixed in commit 7d73b80, but it is unclear to me how self-referential macros are supposed to work. In Emacs, such a macro will trigger infinite recursion.

  2. srhb reporter

    In Vim, a macro will fail if any of its actions fails, such as a missing search term, or attempting to move beyond the last line/word/letter of the buffer. This is often an excellent way to get things done very fast rather than designing complex regexes.

  3. srhb reporter

    In this case, end of file, but yes. A simpler example would be something like


    Which would append WORD to all words until end of buffer. Shame if it's not possible in Emacs at all.

  4. Log in to comment