Gnus development mailing list
 help / color / mirror / Atom feed
From: Sam Steingold <sds@gnu.org>
Subject: Re: follow-up & CC
Date: Wed, 12 Nov 2003 16:13:21 -0500	[thread overview]
Message-ID: <u4qx9e1e6.fsf@gnu.org> (raw)
In-Reply-To: <v9ptfx5pdl.fsf@marauder.physik.uni-ulm.de>

> * Reiner Steib <4.hpr.03.e.f@aheshrefcnz.qr> [2003-11-12 21:00:06 +0100]:
>
> Can `new-header' ever be nil?

no, it is later passed to `insert' which complains about nils.

> BTW, suggestions for a doc-string for
> `message-carefully-insert-headers', anyone?

appended is the new and improved patch.


-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
nobody's life, liberty or property are safe while the legislature is in session


--- message.el.~6.380.~	2003-11-10 15:26:08.612774400 -0500
+++ message.el	2003-11-12 16:08:18.618979700 -0500
@@ -2599,15 +2599,34 @@
 		   (message-get-reply-headers t))))
     (message-carefully-insert-headers headers)))
 
+(defvar message-header-synonyms
+  '((To Cc Bcc))
+  "List of lists of header synonyms.
+E.g., if this list contains a member list with elements `Cc' and `To',
+then `message-carefully-insert-headers' will not insert a `To' header
+when the message is already `Cc'ed to the recipient.")
+
 (defun message-carefully-insert-headers (headers)
+  "Insert the headers, an alist, into the message buffer.
+Does not insert the headers when they are already present there
+or in the synonym headers, defined by `message-header-synonyms'."
   (dolist (header headers)
-    (let ((header-name (symbol-name (car header))))
+    (let* ((header-name (symbol-name (car header)))
+           (new-header (cdr header))
+           (synonyms (loop for synonym in message-header-synonyms
+                       when (memq (car header) synonym) return synonym))
+           (old-header
+            (loop for synonym in synonyms
+              for old-header = (mail-fetch-field (symbol-name synonym))
+              when (and old-header (string-match new-header old-header))
+              return synonym)))
+      (if old-header
+          (message "already have `%s' in `%s'" new-header old-header)
       (when (and (message-position-on-field header-name)
-		 (mail-fetch-field header-name)
-		 (not (string-match "\\` *\\'"
-				    (mail-fetch-field header-name))))
+                   (setq old-header (mail-fetch-field header-name))
+                   (not (string-match "\\` *\\'" old-header)))
 	(insert ", "))
-      (insert (cdr header)))))
+        (insert new-header)))))
 
 (defun message-widen-reply ()
   "Widen the reply to include maximum recipients."




  reply	other threads:[~2003-11-12 21:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-10  1:18 Sam Steingold
2003-11-10 12:30 ` Reiner Steib
2003-11-10 14:47   ` Sam Steingold
2003-11-10 17:44     ` Reiner Steib
2003-11-10 18:04       ` Sam Steingold
2003-11-10 18:54         ` Reiner Steib
2003-11-10 19:12           ` Sam Steingold
2003-11-10 19:26           ` Sam Steingold
2003-11-10 20:26             ` Reiner Steib
2003-11-12 16:05               ` Sam Steingold
2003-11-12 16:54                 ` Reiner Steib
2003-11-12 18:36                   ` Sam Steingold
2003-11-12 20:00                     ` Reiner Steib
2003-11-12 21:13                       ` Sam Steingold [this message]
2003-11-18 16:05                         ` Reiner Steib
2003-11-18 18:50                           ` Sam Steingold
2003-11-18 19:57                             ` Reiner Steib
2003-11-18 20:47                               ` Sam Steingold
2004-01-03 14:07                                 ` Reiner Steib

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=u4qx9e1e6.fsf@gnu.org \
    --to=sds@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).