Subject: bug#44583: 25.3; Emacs aborts with fatal error when a keyboard macro (saved in init.el) is set to run automatically at Emacs startup (Windows 10)

From: Eli Zaretskii <[email-masked]>
Date: Wed, 11 Nov 2020 21:36:03 +0200

> From: [email-masked]
> Date: Wed, 11 Nov 2020 23:51:01 +0530
> 
> I encountered a fatal error which caused Emacs to abort at startup
> (running as Daemon). The actions which led to this bug are as follows:
> 
> 1. I recorded a keyboard macro and inserted its elisp code in init.el
> with the M-x insert-kbd-macro function.
> 
> 2. The elisp code for the macro is
> 
> ;; This macro automatically runs remember-notes on Emacs startup and
> ;; then runs recover-this-file to recover autosave data of notes and
> ;; then enters 'yes' to the minibuffer prompt
> (fset 'remember-notes-my-macro
>    (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([134217848 114 101 109 101 109 98 101 114 45 110 111 116 101 115 return 134217848 114 101 99 111 118 101 114 45 116 104 105 115 45 102 105 108 101 return 121 101 115 return] 0 "%d")) arg)))
> ;; Macro ends here
> 
> 3. I wished for this macro execute automatically when Emacs Daemon is
> launched at System startup. So I added the following line to my init.el
> 
> (remember-notes-my-macro)
> 
> 4. When Emacs is started, I get a dialog box with the following text:

Your macro attempts to prompt the user in the minibuffer, but the
daemon doesn't have a frame to do that.  What was the purpose of
invoking such a macro when you start Emacs as a daemon?