Subject: Re: bug#43386: 27.1; Regression in `report-emacs-bug'

From: Lars Ingebrigtsen <[email-masked]>
Date: Mon, 14 Sep 2020 18:15:01 +0200

Eli Zaretskii <[email-masked]> writes:

> The call to sendmail-query-user-about-smtp is the one that asks about
> how to send, and allows to select mailclient.  But the conditions to
> call it are false, and the rest is history.

Yes, it's due to

commit 3a59cc84069376802ba8fd731b524d78db58262c
Author:     Stefan Monnier <[email-masked]>
AuthorDate: Tue Jul 30 16:37:01 2019 -0400

    * lisp/gnus/message.el: Reduce redundancy with send-mail-function
    
which changed the default of message-send-mail-function.

However, even with that fixed, the code there is misguided.  emacsbug
queries for the method:

  (when (or (and (derived-mode-p 'message-mode)
		 (eq message-send-mail-function 'sendmail-query-once))
	    (and (not (derived-mode-p 'message-mode))
		 (eq send-mail-function 'sendmail-query-once)))
    (sendmail-query-user-about-smtp)

but doesn't do anything with it -- sendmail-query-user-about-smtp just
returns a function.

This is how that function is supposed to be used:

(defun sendmail-query-once ()
  "Query for `send-mail-function' and send mail with it.
This also saves the value of `send-mail-function' via Customize."
  ;; If send-mail-function is already setup, we're incorrectly called
  ;; a second time, probably because someone's using an old value
  ;; of send-mail-function.
  (if (not (eq send-mail-function #'sendmail-query-once))
      (funcall send-mail-function)
    (let ((function (sendmail-query-user-about-smtp)))
      (funcall function)
      (when (y-or-n-p "Save this mail sending choice?")
        (setq send-mail-function function)
        (customize-save-variable 'send-mail-function function)))))

Notice that we offer to set it -- after we've seen that the user can
send successfully, which we can't do from that hook.

So to make this work sensibly requires some refactoring of the code.
I'll have a look at it tomorrowish.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no