Remove arch-tags from all files, since these are no longer needed.
[gnus] / lisp / gnus-cite.el
1 ;;; gnus-cite.el --- parse citations in articles for Gnus
2
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
4 ;;   2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5
6 ;; Author: Per Abhiddenware
7
8 ;; This file is part of GNU Emacs.
9
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.
14
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.
19
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/>.
22
23 ;;; Commentary:
24
25 ;;; Code:
26
27 (eval-when-compile (require 'cl))
28 (eval-when-compile
29   (when (featurep 'xemacs)
30     (require 'easy-mmode))) ; for `define-minor-mode'
31
32 (require 'gnus)
33 (require 'gnus-range)
34 (require 'gnus-art)
35 (require 'message)      ; for message-cite-prefix-regexp
36
37 ;;; Customization:
38
39 (defgroup gnus-cite nil
40   "Citation."
41   :prefix "gnus-cite-"
42   :link '(custom-manual "(gnus)Article Highlighting")
43   :group 'gnus-article)
44
45 (defcustom gnus-cited-opened-text-button-line-format "%(%{[-]%}%)\n"
46   "Format of opened cited text buttons."
47   :group 'gnus-cite
48   :type 'string)
49
50 (defcustom gnus-cited-closed-text-button-line-format "%(%{[+]%}%)\n"
51   "Format of closed cited text buttons."
52   :group 'gnus-cite
53   :type 'string)
54
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."
59   :group 'gnus-cite
60   :type '(choice (const :tag "none" nil)
61                  integer
62                  (cons :tag "Top and Bottom" integer integer)))
63
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."
67   :group 'gnus-cite
68   :type '(choice (const :tag "all" nil)
69                  integer))
70
71 (defcustom gnus-cite-max-prefix 20
72   "Maximum possible length for a citation prefix."
73   :group 'gnus-cite
74   :type 'integer)
75
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."
81   :group 'gnus-cite
82   :type 'regexp)
83
84 (defcustom gnus-supercite-secondary-regexp "^.*\"\\([^\"\n]+\\)\" +=="
85   "Regexp matching mangled Supercite attribution lines.
86 The first regexp group should match the Supercite attribution."
87   :group 'gnus-cite
88   :type 'regexp)
89
90 (defcustom gnus-cite-minimum-match-count 2
91   "Minimum number of identical prefixes before we believe it's a citation."
92   :group 'gnus-cite
93   :type 'integer)
94
95 ;; Some Microsoft products put in a citation that extends to the
96 ;; remainder of the message:
97 ;;
98 ;;     -----Original Message-----
99 ;;     From: ...
100 ;;     To: ...
101 ;;     Sent: ...   [date, in non-RFC-2822 format]
102 ;;     Subject: ...
103 ;;
104 ;;     Cited message, with no prefixes
105 ;;
106 ;; The four headers are always the same.  But note they are prone to
107 ;; folding without additional indentation.
108 ;;
109 ;; Others use "----- Original Message -----" instead, and properly quote
110 ;; the body using "> ".  This style is handled without special cases.
111
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."
115   :group 'gnus-cite
116   :type 'regexp)
117
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."
122   :group 'gnus-cite
123   :type 'regexp)
124
125 (defcustom gnus-cite-unsightly-citation-regexp
126   "^-----Original Message-----\nFrom: \\(.+\n\\)+\n"
127   "Regexp matching Microsoft-type rest-of-message citations."
128   :version "22.1"
129   :group 'gnus-cite
130   :type 'regexp)
131
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."
136   :version "22.1"
137   :group 'gnus-cite
138   :type 'boolean)
139
140 (defface gnus-cite-attribution '((t (:italic t)))
141   "Face used for attribution lines."
142   :group 'gnus-cite)
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")
146
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."
150   :version "22.1"
151   :group 'gnus-cite
152   :type 'face)
153
154 (defface gnus-cite-1 '((((class color)
155                          (background dark))
156                         (:foreground "light blue"))
157                        (((class color)
158                          (background light))
159                         (:foreground "MidnightBlue"))
160                        (t
161                         (:italic t)))
162   "Citation face."
163   :group 'gnus-cite)
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")
167
168 (defface gnus-cite-2 '((((class color)
169                          (background dark))
170                         (:foreground "light cyan"))
171                        (((class color)
172                          (background light))
173                         (:foreground "firebrick"))
174                        (t
175                         (:italic t)))
176   "Citation face."
177   :group 'gnus-cite)
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")
181
182 (defface gnus-cite-3 '((((class color)
183                          (background dark))
184                         (:foreground "light yellow"))
185                        (((class color)
186                          (background light))
187                         (:foreground "dark green"))
188                        (t
189                         (:italic t)))
190   "Citation face."
191   :group 'gnus-cite)
192 ;; backward-compatibility alias
193 (put 'gnus-cite-face-3 'face-alias 'gnus-cite-3)
194 (put 'gnus-cite-face-3 'obsolete-face "22.1")
195
196 (defface gnus-cite-4 '((((class color)
197                          (background dark))
198                         (:foreground "light pink"))
199                        (((class color)
200                          (background light))
201                         (:foreground "OrangeRed"))
202                        (t
203                         (:italic t)))
204   "Citation face."
205   :group 'gnus-cite)
206 ;; backward-compatibility alias
207 (put 'gnus-cite-face-4 'face-alias 'gnus-cite-4)
208 (put 'gnus-cite-face-4 'obsolete-face "22.1")
209
210 (defface gnus-cite-5 '((((class color)
211                          (background dark))
212                         (:foreground "pale green"))
213                        (((class color)
214                          (background light))
215                         (:foreground "dark khaki"))
216                        (t
217                         (:italic t)))
218   "Citation face."
219   :group 'gnus-cite)
220 ;; backward-compatibility alias
221 (put 'gnus-cite-face-5 'face-alias 'gnus-cite-5)
222 (put 'gnus-cite-face-5 'obsolete-face "22.1")
223
224 (defface gnus-cite-6 '((((class color)
225                          (background dark))
226                         (:foreground "beige"))
227                        (((class color)
228                          (background light))
229                         (:foreground "dark violet"))
230                        (t
231                         (:italic t)))
232   "Citation face."
233   :group 'gnus-cite)
234 ;; backward-compatibility alias
235 (put 'gnus-cite-face-6 'face-alias 'gnus-cite-6)
236 (put 'gnus-cite-face-6 'obsolete-face "22.1")
237
238 (defface gnus-cite-7 '((((class color)
239                          (background dark))
240                         (:foreground "orange"))
241                        (((class color)
242                          (background light))
243                         (:foreground "SteelBlue4"))
244                        (t
245                         (:italic t)))
246   "Citation face."
247   :group 'gnus-cite)
248 ;; backward-compatibility alias
249 (put 'gnus-cite-face-7 'face-alias 'gnus-cite-7)
250 (put 'gnus-cite-face-7 'obsolete-face "22.1")
251
252 (defface gnus-cite-8 '((((class color)
253                          (background dark))
254                         (:foreground "magenta"))
255                        (((class color)
256                          (background light))
257                         (:foreground "magenta"))
258                        (t
259                         (:italic t)))
260   "Citation face."
261   :group 'gnus-cite)
262 ;; backward-compatibility alias
263 (put 'gnus-cite-face-8 'face-alias 'gnus-cite-8)
264 (put 'gnus-cite-face-8 'obsolete-face "22.1")
265
266 (defface gnus-cite-9 '((((class color)
267                          (background dark))
268                         (:foreground "violet"))
269                        (((class color)
270                          (background light))
271                         (:foreground "violet"))
272                        (t
273                         (:italic t)))
274   "Citation face."
275   :group 'gnus-cite)
276 ;; backward-compatibility alias
277 (put 'gnus-cite-face-9 'face-alias 'gnus-cite-9)
278 (put 'gnus-cite-face-9 'obsolete-face "22.1")
279
280 (defface gnus-cite-10 '((((class color)
281                           (background dark))
282                          (:foreground "plum1"))
283                         (((class color)
284                           (background light))
285                          (:foreground "medium purple"))
286                         (t
287                          (:italic t)))
288   "Citation face."
289   :group 'gnus-cite)
290 ;; backward-compatibility alias
291 (put 'gnus-cite-face-10 'face-alias 'gnus-cite-10)
292 (put 'gnus-cite-face-10 'obsolete-face "22.1")
293
294 (defface gnus-cite-11 '((((class color)
295                           (background dark))
296                          (:foreground "turquoise"))
297                         (((class color)
298                           (background light))
299                          (:foreground "turquoise"))
300                         (t
301                          (:italic t)))
302   "Citation face."
303   :group 'gnus-cite)
304 ;; backward-compatibility alias
305 (put 'gnus-cite-face-11 'face-alias 'gnus-cite-11)
306 (put 'gnus-cite-face-11 'obsolete-face "22.1")
307
308 (defcustom gnus-cite-face-list
309   '(gnus-cite-1 gnus-cite-2 gnus-cite-3 gnus-cite-4 gnus-cite-5 gnus-cite-6
310                 gnus-cite-7 gnus-cite-8 gnus-cite-9 gnus-cite-10 gnus-cite-11)
311   "*List of faces used for highlighting citations.
312
313 When there are citations from multiple articles in the same message,
314 Gnus will try to give each citation from each article its own face.
315 This should make it easier to see who wrote what."
316   :group 'gnus-cite
317   :type '(repeat face)
318   :set (lambda (symbol value)
319          (prog1
320              (custom-set-default symbol value)
321            (if (boundp 'gnus-message-max-citation-depth)
322                (setq gnus-message-max-citation-depth (length value)))
323            (if (boundp 'gnus-message-citation-keywords)
324                (setq gnus-message-citation-keywords
325                      `((gnus-message-search-citation-line
326                         ,@(let ((list nil)
327                                 (count 1))
328                             (dolist (face value (nreverse list))
329                               (push (list count (list 'quote face) 'prepend t)
330                                     list)
331                               (setq count (1+ count)))))))))))
332
333 (defcustom gnus-cite-hide-percentage 50
334   "Only hide excess citation if above this percentage of the body."
335   :group 'gnus-cite
336   :type 'number)
337
338 (defcustom gnus-cite-hide-absolute 10
339   "Only hide excess citation if above this number of lines in the body."
340   :group 'gnus-cite
341   :type 'integer)
342
343 (defcustom gnus-cite-blank-line-after-header t
344   "If non-nil, put a blank line between the citation header and the button."
345   :group 'gnus-cite
346   :type 'boolean)
347
348 ;; This has to go here because its default value depends on
349 ;; gnus-cite-face-list.
350 (defcustom gnus-article-boring-faces (cons 'gnus-signature gnus-cite-face-list)
351   "List of faces that are not worth reading.
352 If an article has more pages below the one you are looking at, but
353 nothing on those pages is a word of at least three letters that is not
354 in a boring face, then the pages will be skipped."
355   :type '(repeat face)
356   :group 'gnus-article-hiding)
357
358 ;;; Internal Variables:
359
360 (defvar gnus-cite-article nil)
361 (defvar gnus-cite-overlay-list nil)
362
363 (defvar gnus-cite-prefix-alist nil)
364 ;; Alist of citation prefixes.
365 ;; The cdr is a list of lines with that prefix.
366
367 (defvar gnus-cite-attribution-alist nil)
368 ;; Alist of attribution lines.
369 ;; The car is a line number.
370 ;; The cdr is the prefix for the citation started by that line.
371
372 (defvar gnus-cite-loose-prefix-alist nil)
373 ;; Alist of citation prefixes that have no matching attribution.
374 ;; The cdr is a list of lines with that prefix.
375
376 (defvar gnus-cite-loose-attribution-alist nil)
377 ;; Alist of attribution lines that have no matching citation.
378 ;; Each member has the form (WROTE IN PREFIX TAG), where
379 ;; WROTE: is the attribution line number
380 ;; IN: is the line number of the previous line if part of the same attribution,
381 ;; PREFIX: Is the citation prefix of the attribution line(s), and
382 ;; TAG: Is a Supercite tag, if any.
383
384 (defvar gnus-cited-opened-text-button-line-format-alist
385   `((?b (marker-position beg) ?d)
386     (?e (marker-position end) ?d)
387     (?n (count-lines beg end) ?d)
388     (?l (- end beg) ?d)))
389 (defvar gnus-cited-opened-text-button-line-format-spec nil)
390 (defvar gnus-cited-closed-text-button-line-format-alist
391   gnus-cited-opened-text-button-line-format-alist)
392 (defvar gnus-cited-closed-text-button-line-format-spec nil)
393
394
395 ;;; Commands:
396
397 (defun gnus-article-highlight-citation (&optional force same-buffer)
398   "Highlight cited text.
399 Each citation in the article will be highlighted with a different face.
400 The faces are taken from `gnus-cite-face-list'.
401 Attribution lines are highlighted with the same face as the
402 corresponding citation merged with the face `gnus-cite-attribution'.
403
404 Text is considered cited if at least `gnus-cite-minimum-match-count'
405 lines matches `message-cite-prefix-regexp' with the same prefix.
406
407 Lines matching `gnus-cite-attribution-suffix' and perhaps
408 `gnus-cite-attribution-prefix' are considered attribution lines."
409   (interactive (list 'force))
410   (save-excursion
411     (unless same-buffer
412       (set-buffer gnus-article-buffer))
413     (gnus-cite-parse-maybe force)
414     (let ((buffer-read-only nil)
415           (alist gnus-cite-prefix-alist)
416           (faces gnus-cite-face-list)
417           (inhibit-point-motion-hooks t)
418           face entry prefix skip numbers number face-alist)
419       ;; Loop through citation prefixes.
420       (while alist
421         (setq entry (car alist)
422               alist (cdr alist)
423               prefix (car entry)
424               numbers (cdr entry)
425               face (car faces)
426               faces (or (cdr faces) gnus-cite-face-list)
427               face-alist (cons (cons prefix face) face-alist))
428         (while numbers
429           (setq number (car numbers)
430                 numbers (cdr numbers))
431           (and (not (assq number gnus-cite-attribution-alist))
432                (not (assq number gnus-cite-loose-attribution-alist))
433                (gnus-cite-add-face number prefix face))))
434       ;; Loop through attribution lines.
435       (setq alist gnus-cite-attribution-alist)
436       (while alist
437         (setq entry (car alist)
438               alist (cdr alist)
439               number (car entry)
440               prefix (cdr entry)
441               skip (gnus-cite-find-prefix number)
442               face (cdr (assoc prefix face-alist)))
443         ;; Add attribution button.
444         (goto-char (point-min))
445         (forward-line (1- number))
446         (when (re-search-forward gnus-cite-attribution-suffix
447                                  (point-at-eol)
448                                  t)
449           (gnus-article-add-button (match-beginning 1) (match-end 1)
450                                    'gnus-cite-toggle prefix))
451         ;; Highlight attribution line.
452         (gnus-cite-add-face number skip face)
453         (gnus-cite-add-face number skip gnus-cite-attribution-face))
454       ;; Loop through attribution lines.
455       (setq alist gnus-cite-loose-attribution-alist)
456       (while alist
457         (setq entry (car alist)
458               alist (cdr alist)
459               number (car entry)
460               skip (gnus-cite-find-prefix number))
461         (gnus-cite-add-face number skip gnus-cite-attribution-face)))))
462
463 (defun gnus-dissect-cited-text ()
464   "Dissect the article buffer looking for cited text."
465   (save-excursion
466     (set-buffer gnus-article-buffer)
467     (gnus-cite-parse-maybe nil t)
468     (let ((alist gnus-cite-prefix-alist)
469           prefix numbers number marks m)
470       ;; Loop through citation prefixes.
471       (while alist
472         (setq numbers (pop alist)
473               prefix (pop numbers))
474         (while numbers
475           (setq number (pop numbers))
476           (goto-char (point-min))
477           (forward-line number)
478           (push (cons (point-marker) "") marks)
479           (while (and numbers
480                       (= (1- number) (car numbers)))
481             (setq number (pop numbers)))
482           (goto-char (point-min))
483           (forward-line (1- number))
484           (push (cons (point-marker) prefix) marks)))
485       ;; Skip to the beginning of the body.
486       (article-goto-body)
487       (push (cons (point-marker) "") marks)
488       ;; Find the end of the body.
489       (goto-char (point-max))
490       (gnus-article-search-signature)
491       (push (cons (point-marker) "") marks)
492       ;; Sort the marks.
493       (setq marks (sort marks 'car-less-than-car))
494       (let ((omarks marks))
495         (setq marks nil)
496         (while (cdr omarks)
497           (if (= (caar omarks) (caadr omarks))
498               (progn
499                 (unless (equal (cdar omarks) "")
500                   (push (car omarks) marks))
501                 (unless (equal (cdadr omarks) "")
502                   (push (cadr omarks) marks))
503                 (unless (and (equal (cdar omarks) "")
504                              (equal (cdadr omarks) "")
505                              (not (cddr omarks)))
506                   (setq omarks (cdr omarks))))
507             (push (car omarks) marks))
508           (setq omarks (cdr omarks)))
509         (when (car omarks)
510           (push (car omarks) marks))
511         (setq marks (setq m (nreverse marks)))
512         (while (cddr m)
513           (if (and (equal (cdadr m) "")
514                    (equal (cdar m) (cdaddr m))
515                    (goto-char (caadr m))
516                    (forward-line 1)
517                    (= (point) (caaddr m)))
518               (setcdr m (cdddr m))
519             (setq m (cdr m))))
520         marks))))
521
522 (defun gnus-article-fill-cited-article (&optional force width)
523   "Do word wrapping in the current article.
524 If WIDTH (the numerical prefix), use that text width when filling."
525   (interactive (list t current-prefix-arg))
526   (save-excursion
527     (set-buffer gnus-article-buffer)
528     (let ((buffer-read-only nil)
529           (inhibit-point-motion-hooks t)
530           (marks (gnus-dissect-cited-text))
531           (adaptive-fill-mode nil)
532           (filladapt-mode nil)
533           (fill-column (if width (prefix-numeric-value width) fill-column)))
534       (save-restriction
535         (while (cdr marks)
536           (narrow-to-region (caar marks) (caadr marks))
537           (let ((adaptive-fill-regexp
538                  (concat "^" (regexp-quote (cdar marks)) " *"))
539                 (fill-prefix
540                  (if (string= (cdar marks) "") ""
541                    (concat (cdar marks) " ")))
542                 use-hard-newlines)
543             (fill-region (point-min) (point-max)))
544           (set-marker (caar marks) nil)
545           (setq marks (cdr marks)))
546         (when marks
547           (set-marker (caar marks) nil))
548         ;; All this information is now incorrect.
549         (setq gnus-cite-prefix-alist nil
550               gnus-cite-attribution-alist nil
551               gnus-cite-loose-prefix-alist nil
552               gnus-cite-loose-attribution-alist nil
553               gnus-cite-article nil)))))
554
555 (defun gnus-article-natural-long-line-p ()
556   "Return true if the current line is long, and it's natural text."
557   (save-excursion
558     (beginning-of-line)
559     (and
560      ;; The line is long.
561      (> (- (line-end-position) (line-beginning-position))
562         (frame-width))
563      ;; It doesn't start with spaces.
564      (not (looking-at "    "))
565      ;; Not cited text.
566      (let ((line-number (1+ (count-lines (point-min) (point))))
567            citep)
568        (dolist (elem gnus-cite-prefix-alist)
569          (when (member line-number (cdr elem))
570            (setq citep t)))
571        (not citep)))))
572
573 (defun gnus-article-hide-citation (&optional arg force)
574   "Toggle hiding of all cited text except attribution lines.
575 See the documentation for `gnus-article-highlight-citation'.
576 If given a negative prefix, always show; if given a positive prefix,
577 always hide."
578   (interactive (append (gnus-article-hidden-arg) (list 'force)))
579   (gnus-set-format 'cited-opened-text-button t)
580   (gnus-set-format 'cited-closed-text-button t)
581   (save-excursion
582     (set-buffer gnus-article-buffer)
583       (let ((buffer-read-only nil)
584             marks
585             (inhibit-point-motion-hooks t)
586             (props (nconc (list 'article-type 'cite)
587                           gnus-hidden-properties))
588             (point (point-min))
589             found beg end start)
590         (while (setq point
591                      (text-property-any point (point-max)
592                                         'gnus-callback
593                                         'gnus-article-toggle-cited-text))
594           (setq found t)
595           (goto-char point)
596           (gnus-article-toggle-cited-text
597            (get-text-property point 'gnus-data) arg)
598           (forward-line 1)
599           (setq point (point)))
600         (unless found
601           (setq marks (gnus-dissect-cited-text))
602           (while marks
603             (setq beg nil
604                   end nil)
605             (while (and marks (string= (cdar marks) ""))
606               (setq marks (cdr marks)))
607             (when marks
608               (setq beg (caar marks)))
609             (while (and marks (not (string= (cdar marks) "")))
610               (setq marks (cdr marks)))
611             (when marks
612             (setq end (caar marks)))
613             ;; Skip past lines we want to leave visible.
614             (when (and beg end gnus-cited-lines-visible)
615               (goto-char beg)
616               (forward-line (if (consp gnus-cited-lines-visible)
617                                 (car gnus-cited-lines-visible)
618                               gnus-cited-lines-visible))
619               (if (>= (point) end)
620                   (setq beg nil)
621                 (setq beg (point-marker))
622                 (when (consp gnus-cited-lines-visible)
623                   (goto-char end)
624                   (forward-line (- (cdr gnus-cited-lines-visible)))
625                   (if (<= (point) beg)
626                       (setq beg nil)
627                   (setq end (point-marker))))))
628             (when (and beg end)
629               (gnus-add-wash-type 'cite)
630               ;; We use markers for the end-points to facilitate later
631               ;; wrapping and mangling of text.
632               (setq beg (set-marker (make-marker) beg)
633                     end (set-marker (make-marker) end))
634               (gnus-add-text-properties-when 'article-type nil beg end props)
635               (goto-char beg)
636               (when (and gnus-cite-blank-line-after-header
637                          (not (save-excursion (search-backward "\n\n" nil t))))
638                 (insert "\n"))
639               (put-text-property
640                (setq start (point-marker))
641                (progn
642                (gnus-article-add-button
643                 (point)
644                 (progn (eval gnus-cited-closed-text-button-line-format-spec)
645                        (point))
646                 `gnus-article-toggle-cited-text
647                 (list (cons beg end) start))
648                (point))
649                'article-type 'annotation)
650               (set-marker beg (point))))))))
651
652 (defun gnus-article-toggle-cited-text (args &optional arg)
653   "Toggle hiding the text in REGION.
654 ARG can be nil or a number.  Positive means hide, negative
655 means show, nil means toggle."
656   (let* ((region (car args))
657          (beg (car region))
658          (end (cdr region))
659          (start (cadr args))
660          (hidden
661           (text-property-any beg (1- end) 'article-type 'cite))
662          (inhibit-point-motion-hooks t)
663          buffer-read-only)
664     (when (or (null arg)
665               (zerop arg)
666               (and (> arg 0) (not hidden))
667               (and (< arg 0) hidden))
668       (if hidden
669           (progn
670             ;; Can't remove 'cite from g-a-wash-types here because
671             ;; multiple citations may be hidden -jas
672             (gnus-remove-text-properties-when
673              'article-type 'cite beg end
674              (cons 'article-type (cons 'cite
675                                        gnus-hidden-properties))))
676         (gnus-add-wash-type 'cite)
677         (gnus-add-text-properties-when
678          'article-type nil beg end
679          (cons 'article-type (cons 'cite
680                                    gnus-hidden-properties))))
681       (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
682         (gnus-set-mode-line 'article))
683       (save-excursion
684         (goto-char start)
685         (gnus-delete-line)
686         (put-text-property
687          (point)
688          (progn
689            (gnus-article-add-button
690             (point)
691             (progn (eval
692                     (if hidden
693                         gnus-cited-opened-text-button-line-format-spec
694                       gnus-cited-closed-text-button-line-format-spec))
695                    (point))
696             `gnus-article-toggle-cited-text
697             args)
698            (point))
699          'article-type 'annotation)))))
700
701 (defun gnus-article-hide-citation-maybe (&optional arg force)
702   "Toggle hiding of cited text that has an attribution line.
703 If given a negative prefix, always show; if given a positive prefix,
704 always hide.
705 This will do nothing unless at least `gnus-cite-hide-percentage'
706 percent and at least `gnus-cite-hide-absolute' lines of the body is
707 cited text with attributions.  When called interactively, these two
708 variables are ignored.
709 See also the documentation for `gnus-article-highlight-citation'."
710   (interactive (append (gnus-article-hidden-arg) '(force)))
711   (with-current-buffer gnus-article-buffer
712     (gnus-delete-wash-type 'cite)
713     (unless (gnus-article-check-hidden-text 'cite arg)
714       (save-excursion
715         (gnus-cite-parse-maybe force)
716         (article-goto-body)
717         (let ((start (point))
718               (atts gnus-cite-attribution-alist)
719               (buffer-read-only nil)
720               (inhibit-point-motion-hooks t)
721               (hidden 0)
722               total)
723           (goto-char (point-max))
724           (gnus-article-search-signature)
725           (setq total (count-lines start (point)))
726           (while atts
727             (setq hidden (+ hidden (length (cdr (assoc (cdar atts)
728                                                        gnus-cite-prefix-alist))))
729                   atts (cdr atts)))
730           (when (or force
731                     (and (> (* 100 hidden) (* gnus-cite-hide-percentage total))
732                          (> hidden gnus-cite-hide-absolute)))
733             (gnus-add-wash-type 'cite)
734             (setq atts gnus-cite-attribution-alist)
735             (while atts
736               (setq total (cdr (assoc (cdar atts) gnus-cite-prefix-alist))
737                     atts (cdr atts))
738               (while total
739                 (setq hidden (car total)
740                       total (cdr total))
741                 (goto-char (point-min))
742                 (forward-line (1- hidden))
743                 (unless (assq hidden gnus-cite-attribution-alist)
744                   (gnus-add-text-properties
745                    (point) (progn (forward-line 1) (point))
746                    (nconc (list 'article-type 'cite)
747                           gnus-hidden-properties)))))))))
748     (gnus-set-mode-line 'article)))
749
750 (defun gnus-article-hide-citation-in-followups ()
751   "Hide cited text in non-root articles."
752   (interactive)
753   (save-excursion
754     (set-buffer gnus-article-buffer)
755     (let ((article (cdr gnus-article-current)))
756       (unless (save-excursion
757                 (set-buffer gnus-summary-buffer)
758                 (gnus-article-displayed-root-p article))
759         (gnus-article-hide-citation)))))
760
761 ;;; Internal functions:
762
763 (defun gnus-cite-parse-maybe (&optional force no-overlay)
764   "Always parse the buffer."
765   (gnus-cite-localize)
766   ;;Reset parser information.
767   (setq gnus-cite-prefix-alist nil
768         gnus-cite-attribution-alist nil
769         gnus-cite-loose-prefix-alist nil
770         gnus-cite-loose-attribution-alist nil)
771   (unless no-overlay
772     (gnus-cite-delete-overlays))
773   ;; Parse if not too large.
774   (if (and gnus-cite-parse-max-size
775            (> (buffer-size) gnus-cite-parse-max-size))
776       ()
777     (setq gnus-cite-article (cons (car gnus-article-current)
778                                   (cdr gnus-article-current)))
779     (gnus-cite-parse-wrapper)))
780
781 (defun gnus-cite-delete-overlays ()
782   (dolist (overlay gnus-cite-overlay-list)
783     (ignore-errors
784       (when (or (not (gnus-overlay-end overlay))
785                 (and (>= (gnus-overlay-end overlay) (point-min))
786                      (<= (gnus-overlay-end overlay) (point-max))))
787         (setq gnus-cite-overlay-list (delete overlay gnus-cite-overlay-list))
788         (ignore-errors
789           (gnus-delete-overlay overlay))))))
790
791 (defun gnus-cite-parse-wrapper ()
792   ;; Wrap chopped gnus-cite-parse.
793   (article-goto-body)
794   (let ((inhibit-point-motion-hooks t))
795     (save-excursion
796       (gnus-cite-parse-attributions))
797     (save-excursion
798       (gnus-cite-parse))
799     (save-excursion
800       (gnus-cite-connect-attributions))))
801
802 (defun gnus-cite-parse ()
803   ;; Parse and connect citation prefixes and attribution lines.
804
805   ;; Parse current buffer searching for citation prefixes.
806   (let ((line (1+ (count-lines (point-min) (point))))
807         (case-fold-search t)
808         (max (save-excursion
809                (goto-char (point-max))
810                (gnus-article-search-signature)
811                (point)))
812         (prefix-regexp (concat "^\\(" message-cite-prefix-regexp "\\)"))
813         alist entry start begin end numbers prefix guess-limit)
814     ;; Get all potential prefixes in `alist'.
815     (while (< (point) max)
816       ;; Each line.
817       (setq begin (point)
818             guess-limit (progn (skip-chars-forward "^> \t\r\n") (point))
819             end (point-at-bol 2)
820             start end)
821       (goto-char begin)
822       ;; Ignore standard Supercite attribution prefix.
823       (when (and (< guess-limit (+ begin gnus-cite-max-prefix))
824                  (looking-at gnus-supercite-regexp))
825         (if (match-end 1)
826             (setq end (1+ (match-end 1)))
827           (setq end (1+ begin))))
828       ;; Ignore very long prefixes.
829       (when (> end (+ begin gnus-cite-max-prefix))
830         (setq end (+ begin gnus-cite-max-prefix)))
831       ;; Ignore quoted envelope From_.
832       (when (and gnus-cite-ignore-quoted-from
833                  (prog2
834                      (setq case-fold-search nil)
835                      (looking-at ">From ")
836                    (setq case-fold-search t)))
837         (setq end (1+ begin)))
838       (while (re-search-forward prefix-regexp (1- end) t)
839         ;; Each prefix.
840         (setq end (match-end 0)
841               prefix (buffer-substring begin end))
842         (set-text-properties 0 (length prefix) nil prefix)
843         (setq entry (assoc prefix alist))
844         (if entry
845             (setcdr entry (cons line (cdr entry)))
846           (push (list prefix line) alist))
847         (goto-char begin))
848       (goto-char start)
849       (setq line (1+ line)))
850     ;; Horrible special case for some Microsoft mailers.
851     (goto-char (point-min))
852     (setq start t begin nil entry nil)
853     (while start
854       ;; Assume this search ends up at the beginning of a line.
855       (if (re-search-forward gnus-cite-unsightly-citation-regexp max t)
856           (progn
857             (when (number-or-marker-p start)
858               (setq begin (count-lines (point-min) start)
859                     end (count-lines (point-min) (match-beginning 0))))
860             (setq start (match-end 0)))
861         (when (number-or-marker-p start)
862           (setq begin (count-lines (point-min) start)
863                 end (count-lines (point-min) max)))
864         (setq start nil))
865       (when begin
866         (while (< begin end)
867           ;; Need to do 1+ because we're in the bol.
868           (push (setq begin (1+ begin)) entry))))
869     (when entry
870       (push (cons "" entry) alist))
871     ;; We got all the potential prefixes.  Now create
872     ;; `gnus-cite-prefix-alist' containing the oldest prefix for each
873     ;; line that appears at least `gnus-cite-minimum-match-count'
874     ;; times.  First sort them by length.  Longer is older.
875     (setq alist (sort alist (lambda (a b)
876                               (> (length (car a)) (length (car b))))))
877     (while alist
878       (setq entry (car alist)
879             prefix (car entry)
880             numbers (cdr entry)
881             alist (cdr alist))
882       (cond ((null numbers)
883              ;; No lines with this prefix that wasn't also part of
884              ;; a longer prefix.
885              )
886             ((< (length numbers) gnus-cite-minimum-match-count)
887              ;; Too few lines with this prefix.  We keep it a bit
888              ;; longer in case it is an exact match for an attribution
889              ;; line, but we don't remove the line from other
890              ;; prefixes.
891              (push entry gnus-cite-prefix-alist))
892             (t
893              (push entry
894                    gnus-cite-prefix-alist)
895              ;; Remove articles from other prefixes.
896              (let ((loop alist)
897                    current)
898                (while loop
899                  (setq current (car loop)
900                        loop (cdr loop))
901                  (setcdr current
902                          (gnus-set-difference (cdr current) numbers)))))))))
903
904 (defun gnus-cite-parse-attributions ()
905   (let (al-alist)
906     ;; Parse attributions
907     (while (re-search-forward gnus-cite-attribution-suffix (point-max) t)
908       (let* ((start (match-beginning 0))
909              (end (match-end 0))
910              (wrote (count-lines (point-min) end))
911              (prefix (gnus-cite-find-prefix wrote))
912              ;; Check previous line for an attribution leader.
913              (tag (progn
914                     (beginning-of-line 1)
915                     (when (looking-at gnus-supercite-secondary-regexp)
916                       (buffer-substring (match-beginning 1)
917                                         (match-end 1)))))
918              (in (progn
919                    (goto-char start)
920                    (and (re-search-backward gnus-cite-attribution-prefix
921                                             (save-excursion
922                                               (beginning-of-line 0)
923                                               (point))
924                                             t)
925                         (not (re-search-forward gnus-cite-attribution-suffix
926                                                 start t))
927                         (count-lines (point-min) (1+ (point)))))))
928         (when (eq wrote in)
929           (setq in nil))
930         (goto-char end)
931         ;; don't add duplicates
932         (let ((al (buffer-substring (save-excursion (beginning-of-line 0)
933                                                     (1+ (point)))
934                                     end)))
935           (when (not (assoc al al-alist))
936             (push (list wrote in prefix tag)
937                   gnus-cite-loose-attribution-alist)
938             (push (cons al t) al-alist)))))))
939
940 (defun gnus-cite-connect-attributions ()
941   ;; Connect attributions to citations
942
943   ;; No citations have been connected to attribution lines yet.
944   (setq gnus-cite-loose-prefix-alist (append gnus-cite-prefix-alist nil))
945
946   ;; Parse current buffer searching for attribution lines.
947   ;; Find exact supercite citations.
948   (gnus-cite-match-attributions 'small nil
949                                 (lambda (prefix tag)
950                                   (when tag
951                                     (concat "\\`"
952                                             (regexp-quote prefix) "[ \t]*"
953                                             (regexp-quote tag) ">"))))
954   ;; Find loose supercite citations after attributions.
955   (gnus-cite-match-attributions 'small t
956                                 (lambda (prefix tag)
957                                   (when tag
958                                     (concat "\\<"
959                                             (regexp-quote tag)
960                                             "\\>"))))
961   ;; Find loose supercite citations anywhere.
962   (gnus-cite-match-attributions 'small nil
963                                 (lambda (prefix tag)
964                                   (when tag
965                                     (concat "\\<"
966                                             (regexp-quote tag)
967                                             "\\>"))))
968   ;; Find nested citations after attributions.
969   (gnus-cite-match-attributions 'small-if-unique t
970                                 (lambda (prefix tag)
971                                   (concat "\\`" (regexp-quote prefix) ".+")))
972   ;; Find nested citations anywhere.
973   (gnus-cite-match-attributions 'small nil
974                                 (lambda (prefix tag)
975                                   (concat "\\`" (regexp-quote prefix) ".+")))
976   ;; Remove loose prefixes with too few lines.
977   (let ((alist gnus-cite-loose-prefix-alist)
978         entry)
979     (while alist
980       (setq entry (car alist)
981             alist (cdr alist))
982       (when (< (length (cdr entry)) gnus-cite-minimum-match-count)
983         (setq gnus-cite-prefix-alist
984               (delq entry gnus-cite-prefix-alist)
985               gnus-cite-loose-prefix-alist
986               (delq entry gnus-cite-loose-prefix-alist)))))
987   ;; Find flat attributions.
988   (gnus-cite-match-attributions 'first t nil)
989   ;; Find any attributions (are we getting desperate yet?).
990   (gnus-cite-match-attributions 'first nil nil))
991
992 (defun gnus-cite-match-attributions (sort after fun)
993   ;; Match all loose attributions and citations (SORT AFTER FUN) .
994   ;;
995   ;; If SORT is `small', the citation with the shortest prefix will be
996   ;; used, if it is `first' the first prefix will be used, if it is
997   ;; `small-if-unique' the shortest prefix will be used if the
998   ;; attribution line does not share its own prefix with other
999   ;; loose attribution lines, otherwise the first prefix will be used.
1000   ;;
1001   ;; If AFTER is non-nil, only citations after the attribution line
1002   ;; will be considered.
1003   ;;
1004   ;; If FUN is non-nil, it will be called with the arguments (WROTE
1005   ;; PREFIX TAG) and expected to return a regular expression.  Only
1006   ;; citations whose prefix matches the regular expression will be
1007   ;; considered.
1008   ;;
1009   ;; WROTE is the attribution line number.
1010   ;; PREFIX is the attribution line prefix.
1011   ;; TAG is the Supercite tag on the attribution line.
1012   (let ((atts gnus-cite-loose-attribution-alist)
1013         (case-fold-search t)
1014         att wrote in prefix tag regexp limit smallest best size)
1015     (while atts
1016       (setq att (car atts)
1017             atts (cdr atts)
1018             wrote (nth 0 att)
1019             in (nth 1 att)
1020             prefix (nth 2 att)
1021             tag (nth 3 att)
1022             regexp (if fun (funcall fun prefix tag) "")
1023             size (cond ((eq sort 'small) t)
1024                        ((eq sort 'first) nil)
1025                        (t (< (length (gnus-cite-find-loose prefix)) 2)))
1026             limit (if after wrote -1)
1027             smallest 1000000
1028             best nil)
1029       (let ((cites gnus-cite-loose-prefix-alist)
1030             cite candidate numbers first compare)
1031         (while cites
1032           (setq cite (car cites)
1033                 cites (cdr cites)
1034                 candidate (car cite)
1035                 numbers (cdr cite)
1036                 first (apply 'min numbers)
1037                 compare (if size (length candidate) first))
1038           (and (> first limit)
1039                regexp
1040                (string-match regexp candidate)
1041                (< compare smallest)
1042                (setq best cite
1043                      smallest compare))))
1044       (if (null best)
1045           ()
1046         (setq gnus-cite-loose-attribution-alist
1047               (delq att gnus-cite-loose-attribution-alist))
1048         (push (cons wrote (car best)) gnus-cite-attribution-alist)
1049         (when in
1050           (push (cons in (car best)) gnus-cite-attribution-alist))
1051         (when (memq best gnus-cite-loose-prefix-alist)
1052           (let ((loop gnus-cite-prefix-alist)
1053                 (numbers (cdr best))
1054                 current)
1055             (setq gnus-cite-loose-prefix-alist
1056                   (delq best gnus-cite-loose-prefix-alist))
1057             (while loop
1058               (setq current (car loop)
1059                     loop (cdr loop))
1060               (if (eq current best)
1061                   ()
1062                 (setcdr current (gnus-set-difference (cdr current) numbers))
1063                 (when (null (cdr current))
1064                   (setq gnus-cite-loose-prefix-alist
1065                         (delq current gnus-cite-loose-prefix-alist)
1066                         atts (delq current atts)))))))))))
1067
1068 (defun gnus-cite-find-loose (prefix)
1069   ;; Return a list of loose attribution lines prefixed by PREFIX.
1070   (let* ((atts gnus-cite-loose-attribution-alist)
1071          att line lines)
1072     (while atts
1073       (setq att (car atts)
1074             line (car att)
1075             atts (cdr atts))
1076       (when (string-equal (gnus-cite-find-prefix line) prefix)
1077         (push line lines)))
1078     lines))
1079
1080 (defun gnus-cite-add-face (number prefix face)
1081   ;; At line NUMBER, ignore PREFIX and add FACE to the rest of the line.
1082   (when face
1083     (let ((inhibit-point-motion-hooks t)
1084           from to overlay)
1085       (goto-char (point-min))
1086       (when (zerop (forward-line (1- number)))
1087         (forward-char (length prefix))
1088         (skip-chars-forward " \t")
1089         (setq from (point))
1090         (end-of-line 1)
1091         (skip-chars-backward " \t")
1092         (setq to (point))
1093         (when (< from to)
1094           (push (setq overlay (gnus-make-overlay from to))
1095                 gnus-cite-overlay-list)
1096           (gnus-overlay-put overlay 'evaporate t)
1097           (gnus-overlay-put overlay 'face face))))))
1098
1099 (defun gnus-cite-toggle (prefix)
1100   (save-excursion
1101     (set-buffer gnus-article-buffer)
1102     (gnus-cite-parse-maybe nil t)
1103     (let ((buffer-read-only nil)
1104           (numbers (cdr (assoc prefix gnus-cite-prefix-alist)))
1105           (inhibit-point-motion-hooks t)
1106           number)
1107       (while numbers
1108         (setq number (car numbers)
1109               numbers (cdr numbers))
1110         (goto-char (point-min))
1111         (forward-line (1- number))
1112         (cond ((get-text-property (point) 'invisible)
1113                ;; Can't remove 'cite from g-a-wash-types here because
1114                ;; multiple citations may be hidden -jas
1115                (remove-text-properties (point) (progn (forward-line 1) (point))
1116                                        gnus-hidden-properties))
1117               ((assq number gnus-cite-attribution-alist))
1118               (t
1119                (gnus-add-wash-type 'cite)
1120                (gnus-add-text-properties
1121                 (point) (progn (forward-line 1) (point))
1122                 (nconc (list 'article-type 'cite)
1123                        gnus-hidden-properties))))
1124         (let ((gnus-article-mime-handle-alist-1
1125                gnus-article-mime-handle-alist))
1126           (gnus-set-mode-line 'article))))))
1127
1128 (defun gnus-cite-find-prefix (line)
1129   ;; Return citation prefix for LINE.
1130   (let ((alist gnus-cite-prefix-alist)
1131         (prefix "")
1132         entry)
1133     (while alist
1134       (setq entry (car alist)
1135             alist (cdr alist))
1136       (when (memq line (cdr entry))
1137         (setq prefix (car entry))))
1138     prefix))
1139
1140 (defun gnus-cite-localize ()
1141   "Make the citation variables local to the article buffer."
1142   (let ((vars '(gnus-cite-article
1143                 gnus-cite-overlay-list gnus-cite-prefix-alist
1144                 gnus-cite-attribution-alist gnus-cite-loose-prefix-alist
1145                 gnus-cite-loose-attribution-alist)))
1146     (while vars
1147       (make-local-variable (pop vars)))))
1148
1149 (defun gnus-cited-line-p ()
1150   "Say whether the current line is a cited line."
1151   (save-excursion
1152     (beginning-of-line)
1153     (let ((found nil))
1154       (dolist (prefix (mapcar 'car gnus-cite-prefix-alist))
1155         (when (string= (buffer-substring (point) (+ (length prefix) (point)))
1156                        prefix)
1157           (setq found t)))
1158       found)))
1159
1160
1161 ;; Highlighting of different citation levels in message-mode.
1162 ;; - message-cite-prefix will be overridden if this is enabled.
1163
1164 (defvar gnus-message-max-citation-depth
1165   (length gnus-cite-face-list)
1166   "Maximum supported level of citation.")
1167
1168 (defvar gnus-message-cite-prefix-regexp
1169   (concat "^\\(?:" message-cite-prefix-regexp "\\)"))
1170
1171 (defun gnus-message-search-citation-line (limit)
1172   "Search for a cited line and set match data accordingly.
1173 Returns nil if there is no such line before LIMIT, t otherwise."
1174   (when (re-search-forward gnus-message-cite-prefix-regexp limit t)
1175     (let ((cdepth (min (length (apply 'concat
1176                                       (split-string
1177                                        (match-string-no-properties 0)
1178                                        "[ \t [:alnum:]]+")))
1179                        gnus-message-max-citation-depth))
1180           (mlist (make-list (* (1+ gnus-message-max-citation-depth) 2) nil))
1181           (start (point-at-bol))
1182           (end (point-at-eol)))
1183       (setcar mlist start)
1184       (setcar (cdr mlist) end)
1185       (setcar (nthcdr (* cdepth 2) mlist) start)
1186       (setcar (nthcdr (1+ (* cdepth 2)) mlist) end)
1187       (set-match-data mlist))
1188     t))
1189
1190 (defvar gnus-message-citation-keywords
1191   ;; eval-when-compile ;; This breaks in XEmacs
1192   `((gnus-message-search-citation-line
1193      ,@(let ((list nil)
1194              (count 1))
1195          ;; (require 'gnus-cite)
1196          (dolist (face gnus-cite-face-list (nreverse list))
1197            (push (list count (list 'quote face) 'prepend t) list)
1198            (setq count (1+ count)))))) ;;
1199   "Keywords for highlighting different levels of message citations.")
1200
1201 (defvar font-lock-defaults-computed)
1202 (defvar font-lock-keywords)
1203 (defvar font-lock-set-defaults)
1204
1205 (eval-and-compile
1206   (unless (featurep 'xemacs)
1207     (autoload 'font-lock-set-defaults "font-lock")))
1208
1209 (define-minor-mode gnus-message-citation-mode
1210   "Toggle `gnus-message-citation-mode' in current buffer.
1211 This buffer local minor mode provides additional font-lock support for
1212 nested citations.
1213 With prefix ARG, turn `gnus-message-citation-mode' on if and only if ARG
1214 is positive.
1215 Automatically turn `font-lock-mode' on when `gnus-message-citation-mode'
1216 is turned on."
1217   nil ;; init-value
1218   "" ;; lighter
1219   nil ;; keymap
1220   (when (eq major-mode 'message-mode)
1221     (let ((defaults (car (if (featurep 'xemacs)
1222                              (get 'message-mode 'font-lock-defaults)
1223                            font-lock-defaults)))
1224           default keywords)
1225       (while defaults
1226         (setq default (if (consp defaults)
1227                           (pop defaults)
1228                         (prog1
1229                             defaults
1230                           (setq defaults nil))))
1231         (if gnus-message-citation-mode
1232             ;; `gnus-message-citation-keywords' should be the last
1233             ;; elements of the keywords because the others are unlikely
1234             ;; to have the OVERRIDE flags -- XEmacs applies a keyword
1235             ;; having no OVERRIDE flag to matched text even if it has
1236             ;; already other faces, while Emacs doesn't.
1237             (set (make-local-variable default)
1238                  (append (default-value default)
1239                          gnus-message-citation-keywords))
1240           (kill-local-variable default))))
1241     ;; Force `font-lock-set-defaults' to update `font-lock-keywords'.
1242     (if (featurep 'xemacs)
1243         (progn
1244           (require 'font-lock)
1245           (setq font-lock-defaults-computed nil
1246                 font-lock-keywords nil))
1247       (setq font-lock-set-defaults nil))
1248     (font-lock-set-defaults)
1249     (cond ((symbol-value 'font-lock-mode)
1250            (font-lock-fontify-buffer))
1251           (gnus-message-citation-mode
1252            (font-lock-mode 1)))))
1253
1254 (defun turn-on-gnus-message-citation-mode ()
1255   "Turn on `gnus-message-citation-mode'."
1256   (gnus-message-citation-mode 1))
1257 (defun turn-off-gnus-message-citation-mode ()
1258   "Turn off `gnus-message-citation-mode'."
1259   (gnus-message-citation-mode -1))
1260
1261 (gnus-ems-redefine)
1262
1263 (provide 'gnus-cite)
1264
1265 ;; Local Variables:
1266 ;; coding: iso-8859-1
1267 ;; End:
1268
1269 ;;; gnus-cite.el ends here