From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/54791 Path: main.gmane.org!not-for-mail From: Sam Steingold Newsgroups: gmane.emacs.gnus.general Subject: Re: follow-up & CC Date: Wed, 12 Nov 2003 16:13:21 -0500 Organization: disorganization Sender: ding-owner@lists.math.uh.edu Message-ID: References: Reply-To: sds@gnu.org NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1068672063 13604 80.91.224.253 (12 Nov 2003 21:21:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 12 Nov 2003 21:21:03 +0000 (UTC) Original-X-From: ding-owner+M3332@lists.math.uh.edu Wed Nov 12 22:21:01 2003 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AK2Q8-0007OZ-00 for ; Wed, 12 Nov 2003 22:21:01 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1AK2Pw-0001Zb-00; Wed, 12 Nov 2003 15:20:48 -0600 Original-Received: from justine.libertine.org ([66.139.78.221]) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1AK2Ps-0001ZW-00 for ding@lists.math.uh.edu; Wed, 12 Nov 2003 15:20:44 -0600 Original-Received: from main.gmane.org (main.gmane.org [80.91.224.249]) by justine.libertine.org (Postfix) with ESMTP id 1928B3A006F for ; Wed, 12 Nov 2003 15:20:43 -0600 (CST) Original-Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AK2Pq-0005TK-00 for ; Wed, 12 Nov 2003 22:20:42 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: ding@gnus.org Original-Received: from sea.gmane.org ([80.91.224.252]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AK2Ik-0005Os-00 for ; Wed, 12 Nov 2003 22:13:22 +0100 Original-Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AK2Ik-0003F1-00 for ; Wed, 12 Nov 2003 22:13:22 +0100 Original-Lines: 61 Original-X-Complaints-To: usenet@sea.gmane.org X-Attribution: Sam X-Disclaimer: You should not expect anyone to agree with me. User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (windows-nt) Cancel-Lock: sha1:yX+hd6CglOS8Sb48QL/FKf3LfLI= Precedence: bulk Xref: main.gmane.org gmane.emacs.gnus.general:54791 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:54791 > * 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 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."