1 ;;; gnus-cite.el --- parse citations in articles for Gnus
2 ;; Copyright (C) 1995,96 Free Software Foundation, Inc.
4 ;; Author: Per Abrahamsen <abraham@iesd.auc.dk>
5 ;; Keywords: news, mail
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 2, or (at your option)
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; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
34 (defgroup gnus-cite nil
39 (defcustom gnus-cited-text-button-line-format "%(%{[...]%}%)\n"
40 "Format of cited text buttons."
44 (defcustom gnus-cited-lines-visible nil
45 "The number of lines of hidden cited text to remain visible."
47 :type '(choice (const :tag "none" nil)
50 (defcustom gnus-cite-parse-max-size 25000
51 "Maximum article size (in bytes) where parsing citations is allowed.
52 Set it to nil to parse all articles."
54 :type '(choice (const :tag "all" nil)
57 (defcustom gnus-cite-prefix-regexp
58 "^[]>|:}+ ]*[]>|:}+]\\(.*>\\)?\\|^.*>"
59 "Regexp matching the longest possible citation prefix on a line."
63 (defcustom gnus-cite-max-prefix 20
64 "Maximum possible length for a citation prefix."
68 (defcustom gnus-supercite-regexp
69 (concat "^\\(" gnus-cite-prefix-regexp "\\)? *"
70 ">>>>> +\"\\([^\"\n]+\\)\" +==")
71 "Regexp matching normal Supercite attribution lines.
72 The first grouping must match prefixes added by other packages."
76 (defcustom gnus-supercite-secondary-regexp "^.*\"\\([^\"\n]+\\)\" +=="
77 "Regexp matching mangled Supercite attribution lines.
78 The first regexp group should match the Supercite attribution."
82 (defcustom gnus-cite-minimum-match-count 2
83 "Minimum number of identical prefixes before we believe it's a citation."
87 (defcustom gnus-cite-attribution-prefix "in article\\|in <"
88 "Regexp matching the beginning of an attribution line."
92 (defcustom gnus-cite-attribution-suffix
93 "\\(wrote\\|writes\\|said\\|says\\):[ \t]*$"
94 "Regexp matching the end of an attribution line.
95 The text matching the first grouping will be used as a button."
99 (defface gnus-cite-attribution-face '((t
101 "Face used for attribution lines.")
103 (defcustom gnus-cite-attribution-face 'gnus-cite-attribution-face
104 "Face used for attribution lines.
105 It is merged with the face for the cited text belonging to the attribution."
109 (defface gnus-cite-face-1 '((((class color)
111 (:foreground "light blue"))
114 (:foreground "MidnightBlue"))
119 (defface gnus-cite-face-2 '((((class color)
121 (:foreground "light cyan"))
124 (:foreground "firebrick"))
129 (defface gnus-cite-face-3 '((((class color)
131 (:foreground "light yellow"))
134 (:foreground "dark green"))
139 (defface gnus-cite-face-4 '((((class color)
141 (:foreground "light pink"))
144 (:foreground "OrangeRed"))
149 (defface gnus-cite-face-5 '((((class color)
151 (:foreground "pale green"))
154 (:foreground "dark khaki"))
159 (defface gnus-cite-face-6 '((((class color)
161 (:foreground "beige"))
164 (:foreground "dark violet"))
169 (defface gnus-cite-face-7 '((((class color)
171 (:foreground "orange"))
174 (:foreground "SteelBlue4"))
179 (defface gnus-cite-face-8 '((((class color)
181 (:foreground "magenta"))
184 (:foreground "magenta"))
189 (defface gnus-cite-face-9 '((((class color)
191 (:foreground "violet"))
194 (:foreground "violet"))
199 (defface gnus-cite-face-10 '((((class color)
201 (:foreground "medium purple"))
204 (:foreground "medium purple"))
209 (defface gnus-cite-face-11 '((((class color)
211 (:foreground "turquoise"))
214 (:foreground "turquoise"))
219 (defcustom gnus-cite-face-list
220 '(gnus-cite-face-1 gnus-cite-face-2 gnus-cite-face-3 gnus-cite-face-4
221 gnus-cite-face-5 gnus-cite-face-6 gnus-cite-face-7 gnus-cite-face-8
222 gnus-cite-face-9 gnus-cite-face-10 gnus-cite-face-11)
223 "List of faces used for highlighting citations.
225 When there are citations from multiple articles in the same message,
226 Gnus will try to give each citation from each article its own face.
227 This should make it easier to see who wrote what."
229 :type '(repeat face))
231 (defcustom gnus-cite-hide-percentage 50
232 "Only hide excess citation if above this percentage of the body."
236 (defcustom gnus-cite-hide-absolute 10
237 "Only hide excess citation if above this number of lines in the body."
241 ;;; Internal Variables:
243 (defvar gnus-cite-article nil)
245 (defvar gnus-cite-prefix-alist nil)
246 ;; Alist of citation prefixes.
247 ;; The cdr is a list of lines with that prefix.
249 (defvar gnus-cite-attribution-alist nil)
250 ;; Alist of attribution lines.
251 ;; The car is a line number.
252 ;; The cdr is the prefix for the citation started by that line.
254 (defvar gnus-cite-loose-prefix-alist nil)
255 ;; Alist of citation prefixes that have no matching attribution.
256 ;; The cdr is a list of lines with that prefix.
258 (defvar gnus-cite-loose-attribution-alist nil)
259 ;; Alist of attribution lines that have no matching citation.
260 ;; Each member has the form (WROTE IN PREFIX TAG), where
261 ;; WROTE: is the attribution line number
262 ;; IN: is the line number of the previous line if part of the same attribution,
263 ;; PREFIX: Is the citation prefix of the attribution line(s), and
264 ;; TAG: Is a Supercite tag, if any.
266 (defvar gnus-cited-text-button-line-format-alist
267 `((?b (marker-position beg) ?d)
268 (?e (marker-position end) ?d)
269 (?l (- end beg) ?d)))
270 (defvar gnus-cited-text-button-line-format-spec nil)
274 (defun gnus-article-highlight-citation (&optional force)
275 "Highlight cited text.
276 Each citation in the article will be highlighted with a different face.
277 The faces are taken from `gnus-cite-face-list'.
278 Attribution lines are highlighted with the same face as the
279 corresponding citation merged with `gnus-cite-attribution-face'.
281 Text is considered cited if at least `gnus-cite-minimum-match-count'
282 lines matches `gnus-cite-prefix-regexp' with the same prefix.
284 Lines matching `gnus-cite-attribution-suffix' and perhaps
285 `gnus-cite-attribution-prefix' are considered attribution lines."
286 (interactive (list 'force))
288 (set-buffer gnus-article-buffer)
289 (gnus-cite-parse-maybe force)
290 (let ((buffer-read-only nil)
291 (alist gnus-cite-prefix-alist)
292 (faces gnus-cite-face-list)
293 (inhibit-point-motion-hooks t)
294 face entry prefix skip numbers number face-alist)
295 ;; Loop through citation prefixes.
297 (setq entry (car alist)
302 faces (or (cdr faces) gnus-cite-face-list)
303 face-alist (cons (cons prefix face) face-alist))
305 (setq number (car numbers)
306 numbers (cdr numbers))
307 (and (not (assq number gnus-cite-attribution-alist))
308 (not (assq number gnus-cite-loose-attribution-alist))
309 (gnus-cite-add-face number prefix face))))
310 ;; Loop through attribution lines.
311 (setq alist gnus-cite-attribution-alist)
313 (setq entry (car alist)
317 skip (gnus-cite-find-prefix number)
318 face (cdr (assoc prefix face-alist)))
319 ;; Add attribution button.
321 (when (re-search-forward gnus-cite-attribution-suffix
322 (save-excursion (end-of-line 1) (point))
324 (gnus-article-add-button (match-beginning 1) (match-end 1)
325 'gnus-cite-toggle prefix))
326 ;; Highlight attribution line.
327 (gnus-cite-add-face number skip face)
328 (gnus-cite-add-face number skip gnus-cite-attribution-face))
329 ;; Loop through attribution lines.
330 (setq alist gnus-cite-loose-attribution-alist)
332 (setq entry (car alist)
335 skip (gnus-cite-find-prefix number))
336 (gnus-cite-add-face number skip gnus-cite-attribution-face)))))
338 (defun gnus-dissect-cited-text ()
339 "Dissect the article buffer looking for cited text."
341 (set-buffer gnus-article-buffer)
342 (gnus-cite-parse-maybe)
343 (let ((alist gnus-cite-prefix-alist)
344 prefix numbers number marks m)
345 ;; Loop through citation prefixes.
347 (setq numbers (pop alist)
348 prefix (pop numbers))
350 (setq number (pop numbers))
351 (goto-char (point-min))
352 (forward-line number)
353 (push (cons (point-marker) "") marks)
355 (= (1- number) (car numbers)))
356 (setq number (pop numbers)))
357 (goto-char (point-min))
358 (forward-line (1- number))
359 (push (cons (point-marker) prefix) marks)))
360 ;; Skip to the beginning of the body.
361 (goto-char (point-min))
362 (search-forward "\n\n" nil t)
363 (push (cons (point-marker) "") marks)
364 ;; Find the end of the body.
365 (goto-char (point-max))
366 (gnus-article-search-signature)
367 (push (cons (point-marker) "") marks)
369 (setq marks (sort marks (lambda (m1 m2) (< (car m1) (car m2)))))
370 (let ((omarks marks))
373 (if (= (caar omarks) (caadr omarks))
375 (unless (equal (cdar omarks) "")
376 (push (car omarks) marks))
377 (unless (equal (cdadr omarks) "")
378 (push (cadr omarks) marks))
379 (unless (and (equal (cdar omarks) "")
380 (equal (cdadr omarks) "")
382 (setq omarks (cdr omarks))))
383 (push (car omarks) marks))
384 (setq omarks (cdr omarks)))
386 (push (car omarks) marks))
387 (setq marks (setq m (nreverse marks)))
389 (if (and (equal (cdadr m) "")
390 (equal (cdar m) (cdaddr m))
391 (goto-char (caadr m))
393 (= (point) (caaddr m)))
398 (defun gnus-article-fill-cited-article (&optional force)
399 "Do word wrapping in the current article."
400 (interactive (list t))
402 (set-buffer gnus-article-buffer)
403 (let ((buffer-read-only nil)
404 (inhibit-point-motion-hooks t)
405 (marks (gnus-dissect-cited-text))
406 (adaptive-fill-mode nil))
410 (narrow-to-region (caar marks) (caadr marks))
411 (let ((adaptive-fill-regexp
412 (concat "^" (regexp-quote (cdar marks)) " *"))
413 (fill-prefix (cdar marks)))
414 (fill-region (point-min) (point-max)))
415 (set-marker (caar marks) nil)
416 (setq marks (cdr marks)))
418 (set-marker (caar marks) nil))
419 ;; All this information is now incorrect.
420 (setq gnus-cite-prefix-alist nil
421 gnus-cite-attribution-alist nil
422 gnus-cite-loose-prefix-alist nil
423 gnus-cite-loose-attribution-alist nil)))))
425 (defun gnus-article-hide-citation (&optional arg force)
426 "Toggle hiding of all cited text except attribution lines.
427 See the documentation for `gnus-article-highlight-citation'.
428 If given a negative prefix, always show; if given a positive prefix,
430 (interactive (append (gnus-article-hidden-arg) (list 'force)))
431 (setq gnus-cited-text-button-line-format-spec
432 (gnus-parse-format gnus-cited-text-button-line-format
433 gnus-cited-text-button-line-format-alist t))
435 (set-buffer gnus-article-buffer)
437 ((gnus-article-check-hidden-text 'cite arg)
439 ((gnus-article-text-type-exists-p 'cite)
440 (let ((buffer-read-only nil))
441 (gnus-article-hide-text-of-type 'cite)))
443 (let ((buffer-read-only nil)
444 (marks (gnus-dissect-cited-text))
445 (inhibit-point-motion-hooks t)
446 (props (nconc (list 'article-type 'cite)
447 gnus-hidden-properties))
452 (while (and marks (string= (cdar marks) ""))
453 (setq marks (cdr marks)))
455 (setq beg (caar marks)))
456 (while (and marks (not (string= (cdar marks) "")))
457 (setq marks (cdr marks)))
459 (setq end (caar marks)))
460 ;; Skip past lines we want to leave visible.
461 (when (and beg end gnus-cited-lines-visible)
463 (forward-line gnus-cited-lines-visible)
466 (setq beg (point-marker))))
468 (gnus-add-text-properties beg end props)
470 (unless (save-excursion (search-backward "\n\n" nil t))
475 (gnus-article-add-button
477 (progn (eval gnus-cited-text-button-line-format-spec) (point))
478 `gnus-article-toggle-cited-text (cons beg end))
480 'article-type 'annotation)
481 (set-marker beg (point)))))))))
483 (defun gnus-article-toggle-cited-text (region)
484 "Toggle hiding the text in REGION."
485 (let (buffer-read-only)
487 (if (text-property-any
488 (car region) (1- (cdr region))
489 (car gnus-hidden-properties) (cadr gnus-hidden-properties))
490 'remove-text-properties 'gnus-add-text-properties)
491 (car region) (cdr region) gnus-hidden-properties)))
493 (defun gnus-article-hide-citation-maybe (&optional arg force)
494 "Toggle hiding of cited text that has an attribution line.
495 If given a negative prefix, always show; if given a positive prefix,
497 This will do nothing unless at least `gnus-cite-hide-percentage'
498 percent and at least `gnus-cite-hide-absolute' lines of the body is
499 cited text with attributions. When called interactively, these two
500 variables are ignored.
501 See also the documentation for `gnus-article-highlight-citation'."
502 (interactive (append (gnus-article-hidden-arg) (list 'force)))
503 (unless (gnus-article-check-hidden-text 'cite arg)
505 (set-buffer gnus-article-buffer)
506 (gnus-cite-parse-maybe force)
507 (goto-char (point-min))
508 (search-forward "\n\n" nil t)
509 (let ((start (point))
510 (atts gnus-cite-attribution-alist)
511 (buffer-read-only nil)
512 (inhibit-point-motion-hooks t)
515 (goto-char (point-max))
516 (gnus-article-search-signature)
517 (setq total (count-lines start (point)))
519 (setq hiden (+ hiden (length (cdr (assoc (cdar atts)
520 gnus-cite-prefix-alist))))
523 (and (> (* 100 hiden) (* gnus-cite-hide-percentage total))
524 (> hiden gnus-cite-hide-absolute)))
525 (setq atts gnus-cite-attribution-alist)
527 (setq total (cdr (assoc (cdar atts) gnus-cite-prefix-alist))
530 (setq hiden (car total)
533 (unless (assq hiden gnus-cite-attribution-alist)
534 (gnus-add-text-properties
535 (point) (progn (forward-line 1) (point))
536 (nconc (list 'article-type 'cite)
537 gnus-hidden-properties))))))))))
539 (defun gnus-article-hide-citation-in-followups ()
540 "Hide cited text in non-root articles."
543 (set-buffer gnus-article-buffer)
544 (let ((article (cdr gnus-article-current)))
545 (unless (save-excursion
546 (set-buffer gnus-summary-buffer)
547 (gnus-article-displayed-root-p article))
548 (gnus-article-hide-citation)))))
550 ;;; Internal functions:
552 (defun gnus-cite-parse-maybe (&optional force)
553 ;; Parse if the buffer has changes since last time.
554 (if (equal gnus-cite-article gnus-article-current)
556 ;;Reset parser information.
557 (setq gnus-cite-prefix-alist nil
558 gnus-cite-attribution-alist nil
559 gnus-cite-loose-prefix-alist nil
560 gnus-cite-loose-attribution-alist nil)
561 ;; Parse if not too large.
563 gnus-cite-parse-max-size
564 (> (buffer-size) gnus-cite-parse-max-size))
566 (setq gnus-cite-article (cons (car gnus-article-current)
567 (cdr gnus-article-current)))
570 (defun gnus-cite-parse ()
571 ;; Parse and connect citation prefixes and attribution lines.
573 ;; Parse current buffer searching for citation prefixes.
574 (goto-char (point-min))
575 (unless (search-forward "\n\n" nil t)
576 (goto-char (point-max)))
577 (let ((line (1+ (count-lines (point-min) (point))))
580 (goto-char (point-max))
581 (gnus-article-search-signature)
583 alist entry start begin end numbers prefix)
584 ;; Get all potential prefixes in `alist'.
585 (while (< (point) max)
588 end (progn (beginning-of-line 2) (point))
591 ;; Ignore standard Supercite attribution prefix.
592 (when (looking-at gnus-supercite-regexp)
594 (setq end (1+ (match-end 1)))
595 (setq end (1+ begin))))
596 ;; Ignore very long prefixes.
597 (when (> end (+ (point) gnus-cite-max-prefix))
598 (setq end (+ (point) gnus-cite-max-prefix)))
599 (while (re-search-forward gnus-cite-prefix-regexp (1- end) t)
601 (setq end (match-end 0)
602 prefix (buffer-substring begin end))
603 (gnus-set-text-properties 0 (length prefix) nil prefix)
604 (setq entry (assoc prefix alist))
606 (setcdr entry (cons line (cdr entry)))
607 (push (list prefix line) alist))
610 (setq line (1+ line)))
611 ;; We got all the potential prefixes. Now create
612 ;; `gnus-cite-prefix-alist' containing the oldest prefix for each
613 ;; line that appears at least gnus-cite-minimum-match-count
614 ;; times. First sort them by length. Longer is older.
615 (setq alist (sort alist (lambda (a b)
616 (> (length (car a)) (length (car b))))))
618 (setq entry (car alist)
622 (cond ((null numbers)
623 ;; No lines with this prefix that wasn't also part of
626 ((< (length numbers) gnus-cite-minimum-match-count)
627 ;; Too few lines with this prefix. We keep it a bit
628 ;; longer in case it is an exact match for an attribution
629 ;; line, but we don't remove the line from other
631 (push entry gnus-cite-prefix-alist))
634 gnus-cite-prefix-alist)
635 ;; Remove articles from other prefixes.
639 (setq current (car loop)
642 (gnus-set-difference (cdr current) numbers))))))))
643 ;; No citations have been connected to attribution lines yet.
644 (setq gnus-cite-loose-prefix-alist (append gnus-cite-prefix-alist nil))
646 ;; Parse current buffer searching for attribution lines.
647 (goto-char (point-min))
648 (search-forward "\n\n" nil t)
649 (while (re-search-forward gnus-cite-attribution-suffix (point-max) t)
650 (let* ((start (match-beginning 0))
652 (wrote (count-lines (point-min) end))
653 (prefix (gnus-cite-find-prefix wrote))
654 ;; Check previous line for an attribution leader.
656 (beginning-of-line 1)
657 (when (looking-at gnus-supercite-secondary-regexp)
658 (buffer-substring (match-beginning 1)
662 (and (re-search-backward gnus-cite-attribution-prefix
664 (beginning-of-line 0)
667 (not (re-search-forward gnus-cite-attribution-suffix
669 (count-lines (point-min) (1+ (point)))))))
673 (push (list wrote in prefix tag)
674 gnus-cite-loose-attribution-alist)))
675 ;; Find exact supercite citations.
676 (gnus-cite-match-attributions 'small nil
680 (regexp-quote prefix) "[ \t]*"
681 (regexp-quote tag) ">"))))
682 ;; Find loose supercite citations after attributions.
683 (gnus-cite-match-attributions 'small t
689 ;; Find loose supercite citations anywhere.
690 (gnus-cite-match-attributions 'small nil
696 ;; Find nested citations after attributions.
697 (gnus-cite-match-attributions 'small-if-unique t
699 (concat "\\`" (regexp-quote prefix) ".+")))
700 ;; Find nested citations anywhere.
701 (gnus-cite-match-attributions 'small nil
703 (concat "\\`" (regexp-quote prefix) ".+")))
704 ;; Remove loose prefixes with too few lines.
705 (let ((alist gnus-cite-loose-prefix-alist)
708 (setq entry (car alist)
710 (when (< (length (cdr entry)) gnus-cite-minimum-match-count)
711 (setq gnus-cite-prefix-alist
712 (delq entry gnus-cite-prefix-alist)
713 gnus-cite-loose-prefix-alist
714 (delq entry gnus-cite-loose-prefix-alist)))))
715 ;; Find flat attributions.
716 (gnus-cite-match-attributions 'first t nil)
717 ;; Find any attributions (are we getting desperate yet?).
718 (gnus-cite-match-attributions 'first nil nil))
720 (defun gnus-cite-match-attributions (sort after fun)
721 ;; Match all loose attributions and citations (SORT AFTER FUN) .
723 ;; If SORT is `small', the citation with the shortest prefix will be
724 ;; used, if it is `first' the first prefix will be used, if it is
725 ;; `small-if-unique' the shortest prefix will be used if the
726 ;; attribution line does not share its own prefix with other
727 ;; loose attribution lines, otherwise the first prefix will be used.
729 ;; If AFTER is non-nil, only citations after the attribution line
730 ;; will be considered.
732 ;; If FUN is non-nil, it will be called with the arguments (WROTE
733 ;; PREFIX TAG) and expected to return a regular expression. Only
734 ;; citations whose prefix matches the regular expression will be
737 ;; WROTE is the attribution line number.
738 ;; PREFIX is the attribution line prefix.
739 ;; TAG is the Supercite tag on the attribution line.
740 (let ((atts gnus-cite-loose-attribution-alist)
742 att wrote in prefix tag regexp limit smallest best size)
750 regexp (if fun (funcall fun prefix tag) "")
751 size (cond ((eq sort 'small) t)
752 ((eq sort 'first) nil)
753 (t (< (length (gnus-cite-find-loose prefix)) 2)))
754 limit (if after wrote -1)
757 (let ((cites gnus-cite-loose-prefix-alist)
758 cite candidate numbers first compare)
760 (setq cite (car cites)
764 first (apply 'min numbers)
765 compare (if size (length candidate) first))
768 (string-match regexp candidate)
774 (setq gnus-cite-loose-attribution-alist
775 (delq att gnus-cite-loose-attribution-alist))
776 (push (cons wrote (car best)) gnus-cite-attribution-alist)
778 (push (cons in (car best)) gnus-cite-attribution-alist))
779 (when (memq best gnus-cite-loose-prefix-alist)
780 (let ((loop gnus-cite-prefix-alist)
783 (setq gnus-cite-loose-prefix-alist
784 (delq best gnus-cite-loose-prefix-alist))
786 (setq current (car loop)
788 (if (eq current best)
790 (setcdr current (gnus-set-difference (cdr current) numbers))
791 (when (null (cdr current))
792 (setq gnus-cite-loose-prefix-alist
793 (delq current gnus-cite-loose-prefix-alist)
794 atts (delq current atts)))))))))))
796 (defun gnus-cite-find-loose (prefix)
797 ;; Return a list of loose attribution lines prefixed by PREFIX.
798 (let* ((atts gnus-cite-loose-attribution-alist)
804 (when (string-equal (gnus-cite-find-prefix line) prefix)
808 (defun gnus-cite-add-face (number prefix face)
809 ;; At line NUMBER, ignore PREFIX and add FACE to the rest of the line.
811 (let ((inhibit-point-motion-hooks t)
814 (unless (eobp);; Sometimes things become confused.
815 (forward-char (length prefix))
816 (skip-chars-forward " \t")
819 (skip-chars-backward " \t")
822 (gnus-overlay-put (gnus-make-overlay from to) 'face face))))))
824 (defun gnus-cite-toggle (prefix)
826 (set-buffer gnus-article-buffer)
827 (let ((buffer-read-only nil)
828 (numbers (cdr (assoc prefix gnus-cite-prefix-alist)))
829 (inhibit-point-motion-hooks t)
832 (setq number (car numbers)
833 numbers (cdr numbers))
835 (cond ((get-text-property (point) 'invisible)
836 (remove-text-properties (point) (progn (forward-line 1) (point))
837 gnus-hidden-properties))
838 ((assq number gnus-cite-attribution-alist))
840 (gnus-add-text-properties
841 (point) (progn (forward-line 1) (point))
842 (nconc (list 'article-type 'cite)
843 gnus-hidden-properties))))))))
845 (defun gnus-cite-find-prefix (line)
846 ;; Return citation prefix for LINE.
847 (let ((alist gnus-cite-prefix-alist)
851 (setq entry (car alist)
853 (when (memq line (cdr entry))
854 (setq prefix (car entry))))
857 (gnus-add-shutdown 'gnus-cache-close 'gnus)
859 (defun gnus-cache-close ()
860 (setq gnus-cite-prefix-alist nil))
866 ;;; gnus-cite.el ends here