all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Karl Fogel <kfogel@red-bean.com>
To: Emacs developers <emacs-devel@gnu.org>
Subject: Question about `message-options-set-recipient' and friends.
Date: Mon, 04 Nov 2019 14:08:06 -0600	[thread overview]
Message-ID: <87bltr8k42.fsf@red-bean.com> (raw)

While debugging a new problem I encountered with sending OpenPGP-signed replies in Gnus via message-mode, I ran into some confusing code:

The function `message-options-set-recipient' in gnus/message.el is undocumented, but -- if one overlooks a little singular/plural inconsistency -- its name suggests that it sets the recipients (in `message-options').  What it actually does, though, is set *both* the sender and the recipient:

  (defun message-options-set-recipient ()
    (save-restriction
      (message-narrow-to-headers-or-head)
      (message-options-set 'message-sender
  			 (mail-strip-quoted-names
  			  (message-fetch-field "from")))
      (message-options-set 'message-recipients
  			 (mail-strip-quoted-names
  			  (let ((to (message-fetch-field "to"))
  				(cc (message-fetch-field "cc"))
  				(bcc (message-fetch-field "bcc")))
  			    (concat
  			     (or to "")
  			     (if (and to cc) ", ")
  			     (or cc "")
  			     (if (and (or to cc) bcc) ", ")
  			     (or bcc "")))))))

I don't know this code very well, so I'm checking here before making any changes.

What I'd like to do is change its name to `message-options-set-sender-and-recipients' and add a doc string.  I know it's an awkward name, but I couldn't think of anything better.  No functional change is intended here, obviously -- I'm just trying to make the code more comprehensible.  Note that there are various places in the code that call "(message-options-set 'message-recipients SOME-VALUE)" manually.  I'm not proposing to update those calls to use this function, because I don't know what the effects of also setting the sender in those places would be.

One of the things I don't fully understand is exactly what `message-options' does.  Here's how it is defined:

  (defvar	message-options nil
    "Some saved answers when sending message.")
  (make-variable-buffer-local 'message-options)

So is it... a cache of some sort?  What's its lifetime?  When can we count on information being there?  Why is it better to look for a value in `message-options' instead of just doing something like `(message-fetch-field "from")' or whatever?  Why are we saving answers at all when sending a message?

If that variable were fully documented, I'd be able to write better documentation for the function I'm proposing to rename to `message-options-set-sender-and-recipients'.

(By the way, all of the above is yak-shaving on the way to debugging the real problem I encountered, which is that suddenly when replying to GPG-signed message, such that my reply is also set to be GPG-signed, in `mml-secure-epg-sign' the value of `signer-names' in the initial `let' is set to nil because even though `sender' is set correctly to my usual sending email address and protocol is `OpenPGP', `mml-secure-signer-names' returns nil.  I don't know what might have changed recently to cause this; if anyone does, please post.)

Best regards,
-Karl



                 reply	other threads:[~2019-11-04 20:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bltr8k42.fsf@red-bean.com \
    --to=kfogel@red-bean.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.