I was completing the python koans in emacs, and I was using a kdb macro to test my changes in a shell buffer and jump back into the python code. I wanted to take the line number of the next error from the shell buffer so that I could leap to it directly, but because the execution took a moment, it killed the previous output instead.

How can I insert a pause into a macro while I'm recording it?


You can try evaluating (sleep-for n) while executing your macro, using M-:. This causes Emacs's main thread to sleep, so it will delay the rest of your macro actions, but it should not affect getting the output from other processes like Python.

Note that this might cause weird behavior with your cursor if you're getting comint output (like the result of a Python process). You should still get all your output, but the cursor might stop tracking the end. At the very least, I've had that happen sometimes when testing it out now.


I'm guessing from the description, you are running python in the shell buffer? It might make more sense to run python as a synchronous command, or at least use compile to run python.

If you use compile, I think it's easier to just bind a key to that, and then using C-x ` (command-next-error) or M-g n, M-g p (next-error, previous-error) to jump through errors with the built in error parsing.

I just tested using the builtin python-mode, and C-c C-c runs python-shell-send-buffer which starts python and sends the buffer to it. The python shell appears to be error aware so repeatedly calling C-x ` will jump to each line with an error.

I'm not quite following what you mean by it "killing the previous output"? Are you trying to step through errors while simultaneously running the program again?

  • Thank you for your answer. Since the other answer addresses the general question in the title, I am obligated to accept it. However, you more precisely addressed my individual issue and I'm very grateful for that. – Matthew Piziak Dec 12 '14 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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