1 ;;; gnus-cite.el --- parse citations in articles for Gnus
3 ;; Copyright (C) 1995-2015 Free Software Foundation, Inc.
5 ;; Author: Per Abhiddenware
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 (eval-when-compile (require 'cl))
28 (when (featurep 'xemacs)
29 (require 'easy-mmode))) ; for `define-minor-mode'
34 (require 'message) ; for message-cite-prefix-regexp
38 (defgroup gnus-cite nil
41 :link '(custom-manual "(gnus)Article Highlighting")
44 (defcustom gnus-cited-opened-text-button-line-format "%(%{[-]%}%)\n"
45 "Format of opened cited text buttons."
49 (defcustom gnus-cited-closed-text-button-line-format "%(%{[+]%}%)\n"
50 "Format of closed cited text buttons."
54 (defcustom gnus-cited-lines-visible nil
55 "The number of lines of hidden cited text to remain visible.
56 Or a pair (cons) of numbers which are the number of lines at the top
57 and bottom of the text, respectively, to remain visible."
59 :type '(choice (const :tag "none" nil)
61 (cons :tag "Top and Bottom" integer integer)))
63 (defcustom gnus-cite-parse-max-size 25000
64 "Maximum article size (in bytes) where parsing citations is allowed.
65 Set it to nil to parse all articles."
67 :type '(choice (const :tag "all" nil)
70 (defcustom gnus-cite-max-prefix 20
71 "Maximum possible length for a citation prefix."
75 (defcustom gnus-supercite-regexp
76 (concat "^\\(" message-cite-prefix-regexp "\\)? *"
77 ">>>>> +\"\\([^\"\n]+\\)\" +==")
78 "*Regexp matching normal Supercite attribution lines.
79 The first grouping must match prefixes added by other packages."
83 (defcustom gnus-supercite-secondary-regexp "^.*\"\\([^\"\n]+\\)\" +=="
84 "Regexp matching mangled Supercite attribution lines.
85 The first regexp group should match the Supercite attribution."
89 (defcustom gnus-cite-minimum-match-count 2
90 "Minimum number of identical prefixes before we believe it's a citation."
94 ;; Some Microsoft products put in a citation that extends to the
95 ;; remainder of the message:
97 ;; -----Original Message-----
100 ;; Sent: ... [date, in non-RFC-2822 format]
103 ;; Cited message, with no prefixes
105 ;; The four headers are always the same. But note they are prone to
106 ;; folding without additional indentation.
108 ;; Others use "----- Original Message -----" instead, and properly quote
109 ;; the body using "> ". This style is handled without special cases.
111 (defcustom gnus-cite-attribution-prefix
112 "In article\\|in <\\|On \\(Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\|Sun\\),\\|----- ?Original Message ?-----"
113 "*Regexp matching the beginning of an attribution line."
117 (defcustom gnus-cite-attribution-suffix
118 "\\(\\(wrote\\|writes\\|said\\|says\\|>\\)\\(:\\|\\.\\.\\.\\)\\|----- ?Original Message ?-----\\)[ \t]*$"
119 "*Regexp matching the end of an attribution line.
120 The text matching the first grouping will be used as a button."
124 (defcustom gnus-cite-unsightly-citation-regexp
125 "^-----Original Message-----\nFrom: \\(.+\n\\)+\n"
126 "Regexp matching Microsoft-type rest-of-message citations."
131 (defcustom gnus-cite-ignore-quoted-from t
132 "Non-nil means don't regard lines beginning with \">From \" as cited text.
133 Those lines may have been quoted by MTAs in order not to mix up with
134 the envelope From line."
139 (defface gnus-cite-attribution '((t (:italic t)))
140 "Face used for attribution lines."
142 ;; backward-compatibility alias
143 (put 'gnus-cite-attribution-face 'face-alias 'gnus-cite-attribution)
144 (put 'gnus-cite-attribution-face 'obsolete-face "22.1")
146 (defcustom gnus-cite-attribution-face 'gnus-cite-attribution
147 "Face used for attribution lines.
148 It is merged with the face for the cited text belonging to the attribution."
153 (defface gnus-cite-1 '((((class color)
155 (:foreground "light blue"))
158 (:foreground "MidnightBlue"))
163 ;; backward-compatibility alias
164 (put 'gnus-cite-face-1 'face-alias 'gnus-cite-1)
165 (put 'gnus-cite-face-1 'obsolete-face "22.1")
167 (defface gnus-cite-2 '((((class color)
169 (:foreground "light cyan"))
172 (:foreground "firebrick"))
177 ;; backward-compatibility alias
178 (put 'gnus-cite-face-2 'face-alias 'gnus-cite-2)
179 (put 'gnus-cite-face-2 'obsolete-face "22.1")
181 (defface gnus-cite-3 '((((class color)
183 (:foreground "light yellow"))
186 (:foreground "dark green"))
191 ;; backward-compatibility alias
192 (put 'gnus-cite-face-3 'face-alias 'gnus-cite-3)
193 (put 'gnus-cite-face-3 'obsolete-face "22.1")
195 (defface gnus-cite-4 '((((class color)
197 (:foreground "light pink"))
200 (:foreground "OrangeRed"))
205 ;; backward-compatibility alias
206 (put 'gnus-cite-face-4 'face-alias 'gnus-cite-4)
207 (put 'gnus-cite-face-4 'obsolete-face "22.1")
209 (defface gnus-cite-5 '((((class color)
211 (:foreground "pale green"))
214 (:foreground "dark khaki"))
219 ;; backward-compatibility alias
220 (put 'gnus-cite-face-5 'face-alias 'gnus-cite-5)
221 (put 'gnus-cite-face-5 'obsolete-face "22.1")
223 (defface gnus-cite-6 '((((class color)
225 (:foreground "beige"))
228 (:foreground "dark violet"))
233 ;; backward-compatibility alias
234 (put 'gnus-cite-face-6 'face-alias 'gnus-cite-6)
235 (put 'gnus-cite-face-6 'obsolete-face "22.1")