Subject: Re: bug#63816: 29.0.91; Don't prompt to save `send-mail-function' if in `emacs -q'

From: Eli Zaretskii <[email-masked]>
Date: Sat, 03 Jun 2023 11:24:05 +0300

> From: Drew Adams <[email-masked]>
> Date: Wed, 31 May 2023 20:05:54 +0000
> 
> emacs -Q
> M-x report-emacs-bug
> Write a bug report, then `C-c C-c'.
> Confirm sending a report.
> Hit `RET' to accept `mail client' as the send method.
> 
> You're prompted to save that choice:
> 
>   Save this mail sending choice? (y or n) y
> 
> This prompt makes no sense.  You anyway get this error message:
> 
>   Setting 'send-mail-function' temporarily since "emacs -q" would
>   overwrite customizations

Can you try the patch below and see if solves this?

diff --git a/lisp/mail/emacsbug.el b/lisp/mail/emacsbug.el
index f686c04..f88f69d 100644
--- a/lisp/mail/emacsbug.el
+++ b/lisp/mail/emacsbug.el
@@ -455,12 +455,14 @@ report-emacs-bug-hook
     (setq send-mail-function (sendmail-query-user-about-smtp))
     (when (derived-mode-p 'message-mode)
       (setq message-send-mail-function (message-default-send-mail-function))
-      (add-hook 'message-sent-hook
-                (lambda ()
-                  (when (y-or-n-p "Save this mail sending choice?")
-                    (customize-save-variable 'send-mail-function
-                                             send-mail-function)))
-                nil t)))
+      (unless (or (null user-init-file)
+                  (and (null custom-file) init-file-had-error))
+        (add-hook 'message-sent-hook
+                  (lambda ()
+                    (when (y-or-n-p "Save this mail sending choice?")
+                      (customize-save-variable 'send-mail-function
+                                               send-mail-function)))
+                  nil t))))
   (or report-emacs-bug-no-confirmation
       ;; mailclient.el does not need a valid From
       (eq send-mail-function 'mailclient-send-it)