From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/50066 Path: main.gmane.org!not-for-mail From: Michael Shields Newsgroups: gmane.emacs.gnus.general Subject: [PATCH] Better handling for Microsoft citations (resend) Date: Wed, 12 Feb 2003 18:03:01 +0000 Organization: Mad Science Research Labs Sender: owner-ding@hpc.uh.edu Message-ID: <87el6d74x6.fsf@mulligatwani.msrl.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1045073722 5868 80.91.224.249 (12 Feb 2003 18:15:22 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 12 Feb 2003 18:15:22 +0000 (UTC) Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18j1D5-0000UZ-00 for ; Wed, 12 Feb 2003 19:02:15 +0100 Original-Received: from sina.hpc.uh.edu ([129.7.128.10] ident=lists) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 18j1E9-0004nN-00; Wed, 12 Feb 2003 12:03:21 -0600 Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Wed, 12 Feb 2003 12:04:19 -0600 (CST) Original-Received: from sclp3.sclp.com (sclp3.sclp.com [66.230.238.2]) by sina.hpc.uh.edu (8.9.3/8.9.3) with SMTP id MAA05489 for ; Wed, 12 Feb 2003 12:04:08 -0600 (CST) Original-Received: (qmail 28028 invoked by alias); 12 Feb 2003 18:03:02 -0000 Original-Received: (qmail 28023 invoked from network); 12 Feb 2003 18:03:02 -0000 Original-Received: from challah.msrl.com (198.137.194.222) by 66.230.238.6 with SMTP; 12 Feb 2003 18:03:02 -0000 Original-Received: (qmail 21897 invoked from network); 12 Feb 2003 18:03:02 -0000 Original-Received: from localhost (HELO mulligatwani.msrl.com) (127.0.0.1) by localhost with SMTP; 12 Feb 2003 18:03:02 -0000 Original-To: ding@gnus.org Original-Lines: 85 User-Agent: Gnus/5.090016 (Oort Gnus v0.16) XEmacs/21.4 (Military Intelligence) Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:50066 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:50066 Resending since I now have papers on file. 2003-02-13 Michael Shields * gnus-cite.el (gnus-cite-attribution-suffix, gnus-cite-parse): Better handling for Microsoft citation styles. (gnus-unsightly-citation-regexp): New. Index: lisp/gnus-cite.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/gnus-cite.el,v retrieving revision 6.21 diff -u -r6.21 gnus-cite.el --- lisp/gnus-cite.el 12 Feb 2003 15:06:16 -0000 6.21 +++ lisp/gnus-cite.el 12 Feb 2003 18:03:16 -0000 @@ -90,19 +90,42 @@ :group 'gnus-cite :type 'integer) +;; Some Microsoft products put in a citation that extends to the +;; remainder of the message: +;; +;; -----Original Message----- +;; From: ... +;; To: ... +;; Sent: ... [date, in non-RFC-2822 format] +;; Subject: ... +;; +;; Cited message, with no prefixes +;; +;; The four headers are always the same. But note they are prone to +;; folding without additional indentation. +;; +;; Others use "----- Original Message -----" instead, and properly quote +;; the body using "> ". This style is handled without special cases. + (defcustom gnus-cite-attribution-prefix - "In article\\|in <\\|On \\(Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\|Sun\\),\\|-----Original Message-----" + "In article\\|in <\\|On \\(Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\|Sun\\),\\|----- ?Original Message ?-----" "*Regexp matching the beginning of an attribution line." :group 'gnus-cite :type 'regexp) (defcustom gnus-cite-attribution-suffix - "\\(\\(wrote\\|writes\\|said\\|says\\|>\\)\\(:\\|\\.\\.\\.\\)\\|-----Original Message-----\\)[ \t]*$" + "\\(\\(wrote\\|writes\\|said\\|says\\|>\\)\\(:\\|\\.\\.\\.\\)\\|----- ?Original Message ?-----\\)[ \t]*$" "*Regexp matching the end of an attribution line. The text matching the first grouping will be used as a button." :group 'gnus-cite :type 'regexp) +(defcustom gnus-unsightly-citation-regexp + "^-----Original Message-----\nFrom: \\(.+\n\\)+\n" + "Regexp matching Microsoft-type rest-of-message citations." + :group 'gnus-cite + :type 'regexp) + (defface gnus-cite-attribution-face '((t (:italic t))) "Face used for attribution lines.") @@ -724,9 +747,19 @@ (goto-char begin)) (goto-char start) (setq line (1+ line))) + ;; Horrible special case for some Microsoft mailers. + (goto-char (point-min)) + (when (re-search-forward gnus-unsightly-citation-regexp max t) + (setq begin (count-lines (point-min) (point))) + (setq end (count-lines (point-min) max)) + (setq entry nil) + (while (< begin end) + (push begin entry) + (setq begin (1+ begin))) + (push (cons "" entry) alist)) ;; We got all the potential prefixes. Now create ;; `gnus-cite-prefix-alist' containing the oldest prefix for each - ;; line that appears at least gnus-cite-minimum-match-count + ;; line that appears at least `gnus-cite-minimum-match-count' ;; times. First sort them by length. Longer is older. (setq alist (sort alist (lambda (a b) (> (length (car a)) (length (car b)))))) -- Shields.