1 ;;; gnus-cite.el --- parse citations in articles for Gnus
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
4 ;; 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: Per Abhiddenware
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 (eval-when-compile (require 'cl))
29 (when (featurep 'xemacs)
30 (require 'easy-mmode))) ; for `define-minor-mode'
35 (require 'message) ; for message-cite-prefix-regexp
39 (defgroup gnus-cite nil
42 :link '(custom-manual "(gnus)Article Highlighting")
45 (defcustom gnus-cited-opened-text-button-line-format "%(%{[-]%}%)\n"
46 "Format of opened cited text buttons."
50 (defcustom gnus-cited-closed-text-button-line-format "%(%{[+]%}%)\n"
51 "Format of closed cited text buttons."
55 (defcustom gnus-cited-lines-visible nil
56 "The number of lines of hidden cited text to remain visible.
57 Or a pair (cons) of numbers which are the number of lines at the top
58 and bottom of the text, respectively, to remain visible."
60 :type '(choice (const :tag "none" nil)
62 (cons :tag "Top and Bottom" integer integer)))
64 (defcustom gnus-cite-parse-max-size 25000
65 "Maximum article size (in bytes) where parsing citations is allowed.
66 Set it to nil to parse all articles."
68 :type '(choice (const :tag "all" nil)
71 (defcustom gnus-cite-max-prefix 20
72 "Maximum possible length for a citation prefix."
76 (defcustom gnus-supercite-regexp
77 (concat "^\\(" message-cite-prefix-regexp "\\)? *"
78 ">>>>> +\"\\([^\"\n]+\\)\" +==")
79 "*Regexp matching normal Supercite attribution lines.
80 The first grouping must match prefixes added by other packages."
84 (defcustom gnus-supercite-secondary-regexp "^.*\"\\([^\"\n]+\\)\" +=="
85 "Regexp matching mangled Supercite attribution lines.
86 The first regexp group should match the Supercite attribution."
90 (defcustom gnus-cite-minimum-match-count 2
91 "Minimum number of identical prefixes before we believe it's a citation."
95 ;; Some Microsoft products put in a citation that extends to the
96 ;; remainder of the message:
98 ;; -----Original Message-----
101 ;; Sent: ... [date, in non-RFC-2822 format]
104 ;; Cited message, with no prefixes
106 ;; The four headers are always the same. But note they are prone to
107 ;; folding without additional indentation.
109 ;; Others use "----- Original Message -----" instead, and properly quote
110 ;; the body using "> ". This style is handled without special cases.
112 (defcustom gnus-cite-attribution-prefix
113 "In article\\|in <\\|On \\(Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\|Sun\\),\\|----- ?Original Message ?-----"
114 "*Regexp matching the beginning of an attribution line."
118 (defcustom gnus-cite-attribution-suffix
119 "\\(\\(wrote\\|writes\\|said\\|says\\|>\\)\\(:\\|\\.\\.\\.\\)\\|----- ?Original Message ?-----\\)[ \t]*$"
120 "*Regexp matching the end of an attribution line.
121 The text matching the first grouping will be used as a button."
125 (defcustom gnus-cite-unsightly-citation-regexp
126 "^-----Original Message-----\nFrom: \\(.+\n\\)+\n"
127 "Regexp matching Microsoft-type rest-of-message citations."
132 (defcustom gnus-cite-ignore-quoted-from t
133 "Non-nil means don't regard lines beginning with \">From \" as cited text.
134 Those lines may have been quoted by MTAs in order not to mix up with
135 the envelope From line."
140 (defface gnus-cite-attribution '((t (:italic t)))
141 "Face used for attribution lines."
143 ;; backward-compatibility alias
144 (put 'gnus-cite-attribution-face 'face-alias 'gnus-cite-attribution)
145 (put 'gnus-cite-attribution-face 'obsolete-face "22.1")
147 (defcustom gnus-cite-attribution-face 'gnus-cite-attribution
148 "Face used for attribution lines.
149 It is merged with the face for the cited text belonging to the attribution."
154 (defface gnus-cite-1 '((((class color)
156 (:foreground "light blue"))
159 (:foreground "MidnightBlue"))
164 ;; backward-compatibility alias
165 (put 'gnus-cite-face-1 'face-alias 'gnus-cite-1)
166 (put 'gnus-cite-face-1 'obsolete-face "22.1")
168 (defface gnus-cite-2 '((((class color)
170 (:foreground "light cyan"))
173 (:foreground "firebrick"))
178 ;; backward-compatibility alias
179 (put 'gnus-cite-face-2 'face-alias 'gnus-cite-2)
180 (put 'gnus-cite-face-2 'obsolete-face "22.1")
182 (defface gnus-cite-3 '((((class color)