- You start recording a macro:
- You do some stuff, let's say
- You run a command that throws an error, let's say
C-g(e.g. you mistakenly run
C-sand you have to cancel that with
C-g, now your work is lost).
Now your recording so far is lost.
I would like to resume where I left off before I ran a command which interrupted my recording. I looked at
C-h f start-kbd-macro, but it's written in C, so I can't tweak it. I also hunted around for a variable like
current-kbd-macro, but found none so far.
Can it be recovered?
I couldn't figure out why
C-u C-x ( wasn't working for me, but I've discovered it's because I was testing with
It turns out that
C-g is special -- if you trigger a different kind of error e.g.
C-x ( M-: (signal 'quit nil)
Then this will stop the recording, but
last-kbd-macro will contain
"M-: M-( signal 'quit nil", but with
C-x ( C-g
This stops recording and discards anything recorded. As a C-g-happy user (as are at least two of my friends), this is a rather unfortunate distinction. I tried editing
keyboard-quit, but there's nothing I can do in there.
It looks like the only way to recover this is via
recent-keys and automatically figuring out where a start-kbd-macro (or similar) was called, as in