Subject: bug#67638: Description of the variable message-mail-user-agent in Emacs 29.1

From: Eli Zaretskii <[email-masked]>
Date: Fri, 08 Dec 2023 14:32:22 +0200

> Date: Fri, 08 Dec 2023 11:41:34 +0000
> From: [email-masked]
> Cc: [email-masked]
> 
> > Oh, and message-setup binds mail-user-agent to a value derived from
> > message-mail-user-agent.  Maybe this is the missing piece you were
> > looking for.
> 
> This may be the key. Let's see if I understand correctly. I would be 
> immensely grateful if you could check the "decision-making pseudocode" 
> below.
> 
> CASE A. We're outside of message.el
> 
> In this case check the variable mail-user-agent to decide how to create 
> the email. mail-user-agent may say to use something different from the 
> Message package, in which case message-mail-user-agent will never 
> intervene unless we use Gnus, and it doesn't matter what it's set up to.
> 
> CASE B. We're inside of message.el
> 
> This may happen either because mail-user-agent is set to the Message 
> package, so brings us to use message.el, or because we're inside Gnus 
> which always calls the Message package no matter the value of 
> mail-user-agent.
> 
> Now that we're in message.el, first we look at message-mail-user-agent 
> and temporarily ignore mail-user-agent:
> CASE B.1 It's the Message package, so send the email this way. Note that 
> mail-user-agent does not intervene at all here in B.1, except perhaps to 
> choose case B instead of case A.
> CASE B.2 It's something else from the Message package and is explicitly 
> set: use that whatever it is. Note that also in this case then 
> mail-user-agent doesn't matter, except perhaps to choose case B instead 
> of case A.
> Case B.3 It says to look at the value of mail-user-agent. Then if it's 
> the message package, this is the same as case B.1 (except that inside 
> B.3 we have used the value of mail-user-agent), otherwise use whatever 
> other package mail-user-agent says to use.
> 
> Do you think this is correct?

Almost.  In case B.1 we do involve mail-user-agent: message.el binds
its value to what message-mail-user-agent tells it.  IOW, the
lower-level functionality of composing and sending email always looks
at mail-user-agent, so any package that wants to override the value of
mail-user-agent must bind it to some other value.