2017-11-06 Keyboard macros and asynchronicity

Some time ago I wanted to send a bunch of emails from mu4e. I had all the data in a csv file, so I figured out that I’ll just record a keyboard macro of myself sending the email and press f4 a few times.

Well, it didn’t work. I’m not 100% sure what the reason was, but it seems to me that after sending an email, mu4e goes back to the main menu in an asynchronous way. This means that if I change the buffer fast enough after sending the message, mu4e will kick in after that and display its main menu. I’m not that fast, of course, but keyboard macros are.

Well, Elisp to the rescue:

(defun pause (count)
  "Pause for a second (or COUNT seconds)."
  (interactive "p")
  (sleep-for count))

I just bound the above command to some convenient key (f7 in my case), pressed it after sending the email while recording the macro, and everything worked! My macro properly returned to the next line of my csv with email addresses, subjects and bodies of my messages.

CategoryEnglish, CategoryBlog, CategoryEmacs