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

From: [email-masked]
Date: Fri, 08 Dec 2023 14:37:30 +0000

>> 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.

Wait up I disagree: case B.1 means that the value of 
message-mail-user-agent is nil, therefore in message-setup the 
expression:

https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/gnus/message.el?id=841614c72272146fff1b9afa05d52150da6d6e66#n6814

is true, therefore we call:

https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/gnus/message.el?id=841614c72272146fff1b9afa05d52150da6d6e66#n6815

and there's no mail-user-agent involved and message.el doesn't touch the 
value of mail-user-agent in case B.1. The value of mail-user-agent is 
changed only in

https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/gnus/message.el?id=841614c72272146fff1b9afa05d52150da6d6e66#n6825

which lies in the part of the "if" that is not run.