all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Question about `message-options-set-recipient' and friends.
@ 2019-11-04 20:08 Karl Fogel
  0 siblings, 0 replies; only message in thread
From: Karl Fogel @ 2019-11-04 20:08 UTC (permalink / raw
  To: Emacs developers

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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-11-04 20:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-04 20:08 Question about `message-options-set-recipient' and friends Karl Fogel

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.