I mistakenly ran a keyboard macro with an Infinite Argument, which made the macro execute endlessly. Take the following example, which just inserts the character a:

C-x ( a C-x )

If I then run:

C-u 0 C-x e

in the *scratch* buffer, the newly defined keyboard macro will be executed over and over again.

I tried C-g several times, as well as ESC-ESC-ESC, but the execution did not stop, and I had to kill Emacs, as it was not responding. Is there any way to halt the execution of a macro without losing the Emacs session?

In case it makes a difference, the Emacs version I tried is 24.3.1.

  • When Emacs hangs it might be still possible to enter debugger by sending it a signal: emacs.stackexchange.com/questions/7565 - here's how to do it.
    – wvxvw
    Commented Mar 9, 2015 at 14:39
  • 1
    C-g should work (it just did for me). Try holding it down.
    – nanny
    Commented Mar 9, 2015 at 14:40

1 Answer 1


C-g works for me, starting from emacs -Q (no init file). I did that with both Emacs 24.3 and a recent development snapshot for Emacs 25.

If you can give a recipe to reproduce what you see, starting from emacs -Q, consider sending a bug report: M-x report-emacs-bug.

  • That's right, I tried it on my home computer (Emacs and C-g worked fine. I will consider sending a bug report. Thanks!
    – Keta
    Commented Mar 13, 2015 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.