Synch to Gnus 200311181602.
authoryamaoka <yamaoka>
Tue, 18 Nov 2003 21:58:47 +0000 (21:58 +0000)
committeryamaoka <yamaoka>
Tue, 18 Nov 2003 21:58:47 +0000 (21:58 +0000)
lisp/ChangeLog
lisp/message.el

index 432d393..de7a766 100644 (file)
@@ -1,3 +1,10 @@
+2003-11-18  Reiner Steib  <Reiner.Steib@gmx.de>
+
+       * message.el (message-insert-to): Don't use `gnus-message'.
+       (message-header-synonyms): New variable.
+       (message-carefully-insert-headers): Use it (check for synonyms).
+       Added doc-string.  From Sam Steingold <sds@gnu.org>.
+
 2003-11-17  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * html2text.el (html2text-remove-tags): Remove the tag in a
 2003-11-17  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * html2text.el (html2text-remove-tags): Remove the tag in a
index fed132e..fed9efc 100644 (file)
@@ -2847,8 +2847,7 @@ prefix FORCE is given."
                  (message-fetch-reply-field "reply-to")
                  (message-fetch-reply-field "from"))))
     (when (and dont to)
                  (message-fetch-reply-field "reply-to")
                  (message-fetch-reply-field "from"))))
     (when (and dont to)
-      (gnus-message
-       3
+      (message
        (if force
           "Ignoring the user request not to have copies sent via mail"
         "Complying with the user request not to have copies sent via mail")))
        (if force
           "Ignoring the user request not to have copies sent via mail"
         "Complying with the user request not to have copies sent via mail")))
@@ -2864,15 +2863,34 @@ prefix FORCE is given."
                   (message-get-reply-headers t))))
     (message-carefully-insert-headers headers)))
 
                   (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)
 (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)
   (dolist (header headers)
-    (let ((header-name (symbol-name (car header))))
-      (when (and (message-position-on-field header-name)
-                (mail-fetch-field header-name)
-                (not (string-match "\\` *\\'"
-                                   (mail-fetch-field header-name))))
-       (insert ", "))
-      (insert (cdr 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)
+                   (setq old-header (mail-fetch-field header-name))
+                   (not (string-match "\\` *\\'" old-header)))
+         (insert ", "))
+        (insert new-header)))))
 
 (defun message-widen-reply ()
   "Widen the reply to include maximum recipients."
 
 (defun message-widen-reply ()
   "Widen the reply to include maximum recipients."