1 ;;; gnus-cite.el --- parse citations in articles for Gnus
2 ;; Copyright (C) 1995,96,97 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-cite-reply-regexp
40 "^\\(Subject: Re\\|In-Reply-To\\|References\\):"
41 "If headers match this regexp it is reasonable to believe that
42 article has citations."
46 (defcustom gnus-cite-always-check nil
47 "Check article always for citations. Set it t to check all articles."
49 :type '(choice (const :tag "no" nil)
50 (const :tag "yes" t)))
52 (defcustom gnus-cited-text-button-line-format "%(%{[...]%}%)\n"
53 "Format of cited text buttons."
57 (defcustom gnus-cited-lines-visible nil
58 "The number of lines of hidden cited text to remain visible."
60 :type '(choice (const :tag "none" nil)
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-prefix-regexp
71 "^[]>|:}+ ]*[]>|:}+]\\(.*>\\)?\\|^.*>"
72 "Regexp matching the longest possible citation prefix on a line."
76 (defcustom gnus-cite-max-prefix 20
77 "Maximum possible length for a citation prefix."
81 (defcustom gnus-supercite-regexp
82 (concat "^\\(" gnus-cite-prefix-regexp "\\)? *"
83 ">>>>> +\"\\([^\"\n]+\\)\" +==")
84 "Regexp matching normal Supercite attribution lines.
85 The first grouping must match prefixes added by other packages."
89 (defcustom gnus-supercite-secondary-regexp "^.*\"\\([^\"\n]+\\)\" +=="
90 "Regexp matching mangled Supercite attribution lines.
91 The first regexp group should match the Supercite attribution."
95 (defcustom gnus-cite-minimum-match-count 2
96 "Minimum number of identical prefixes before we believe it's a citation."
100 (defcustom gnus-cite-attribution-prefix "in article\\|in <"
101 "Regexp matching the beginning of an attribution line."
105 (defcustom gnus-cite-attribution-suffix
106 "\\(wrote\\|writes\\|said\\|says\\):[ \t]*$"
107 "Regexp matching the end of an attribution line.
108 The text matching the first grouping will be used as a button."
112 (defface gnus-cite-attribution-face '((t
114 "Face used for attribution lines.")
116 (defcustom gnus-cite-attribution-face 'gnus-cite-attribution-face
117 "Face used for attribution lines.
118 It is merged with the face for the cited text belonging to the attribution."
122 (defface gnus-cite-face-1 '((((class color)
124 (:foreground "light blue"))
127 (:foreground "MidnightBlue"))
132 (defface gnus-cite-face-2 '((((class color)
134 (:foreground "light cyan"))
137 (:foreground "firebrick"))
142 (defface gnus-cite-face-3 '((((class color)
144 (:foreground "light yellow"))
147 (:foreground "dark green"))
152 (defface gnus-cite-face-4 '((((class color)
154 (:foreground "light pink"))
157 (:foreground "OrangeRed"))
162 (defface gnus-cite-face-5 '((((class color)
164 (:foreground "pale green"))
167 (:foreground "dark khaki"))
172 (defface gnus-cite-face-6 '((((class color)
174 (:foreground "beige"))
177 (:foreground "dark violet"))
182 (defface gnus-cite-face-7 '((((class color)
184 (:foreground "orange"))
187 (:foreground "SteelBlue4"))
192 (defface gnus-cite-face-8 '((((class color)
194 (:foreground "magenta"))
197 (:foreground "magenta"))
202 (defface gnus-cite-face-9 '((((class color)
204 (:foreground "violet"))
207 (:foreground "violet"))
212 (defface gnus-cite-face-10 '((((class color)
214 (:foreground "medium purple"))
217 (:foreground "medium purple"))
222 (defface gnus-cite-face-11 '((((class color)
224 (:foreground "turquoise"))
227 (:foreground "turquoise"))
232 (defcustom gnus-cite-face-list
233 '(gnus-cite-face-1 gnus-cite-face-2 gnus-cite-face-3 gnus-cite-face-4
234 gnus-cite-face-5 gnus-cite-face-6 gnus-cite-face-7 gnus-cite-face-8
235 gnus-cite-face-9 gnus-cite-face-10 gnus-cite-face-11)
236 "List of faces used for highlighting citations.
238 When there are citations from multiple articles in the same message,
239 Gnus will try to give each citation from each article its own face.
240 This should make it easier to see who wrote what."
242 :type '(repeat face))
244 (defcustom gnus-cite-hide-percentage 50
245 "Only hide excess citation if above this percentage of the body."
249 (defcustom gnus-cite-hide-absolute 10
250 "Only hide excess citation if above this number of lines in the body."
254 ;;; Internal Variables:
256 (defvar gnus-cite-article nil)
258 (defvar gnus-cite-prefix-alist nil)
259 ;; Alist of citation prefixes.
260 ;; The cdr is a list of lines with that prefix.
262 (defvar gnus-cite-attribution-alist nil)
263 ;; Alist of attribution lines.
264 ;; The car is a line number.
265 ;; The cdr is the prefix for the citation started by that line.
267 (defvar gnus-cite-loose-prefix-alist nil)
268 ;; Alist of citation prefixes that have no matching attribution.
269 ;; The cdr is a list of lines with that prefix.
271 (defvar gnus-cite-loose-attribution-alist nil)
272 ;; Alist of attribution lines that have no matching citation.
273 ;; Each member has the form (WROTE IN PREFIX TAG), where
274 ;; WROTE: is the attribution line number
275 ;; IN: is the line number of the previous line if part of the same attribution,
276 ;; PREFIX: Is the citation prefix of the attribution line(s), and
277 ;; TAG: Is a Supercite tag, if any.
279 (defvar gnus-cited-text-button-line-format-alist
280 `((?b (marker-position beg) ?d)
281 (?e (marker-position end) ?d)
282 (?l (- end beg) ?d)))
283 (defvar gnus-cited-text-button-line-format-spec nil)
287 (defun gnus-article-highlight-citation (&optional force)
288 "Highlight cited text.
289 Each citation in the article will be highlighted with a different face.
290 The faces are taken from `gnus-cite-face-list'.
291 Attribution lines are highlighted with the same face as the
292 corresponding citation merged with `gnus-cite-attribution-face'.
294 Text is considered cited if at least `gnus-cite-minimum-match-count'
295 lines matches `gnus-cite-prefix-regexp' with the same prefix.
297 Lines matching `gnus-cite-attribution-suffix' and perhaps
298 `gnus-cite-attribution-prefix' are considered attribution lines."
299 (interactive (list 'force))
301 (set-buffer gnus-article-buffer)
302 (gnus-cite-parse-maybe force)
303 (let ((buffer-read-only nil)
304 (alist gnus-cite-prefix-alist)
305 (faces gnus-cite-face-list)
306 (inhibit-point-motion-hooks t)
307 face entry prefix skip numbers number face-alist)
308 ;; Loop through citation prefixes.
310 (setq entry (car alist)
315 faces (or (cdr faces) gnus-cite-face-list)
316 face-alist (cons (cons prefix face) face-alist))
318 (setq number (car numbers)
319 numbers (cdr numbers))
320 (and (not (assq number gnus-cite-attribution-alist))
321 (not (assq number gnus-cite-loose-attribution-alist))
322 (gnus-cite-add-face number prefix face))))
323 ;; Loop through attribution lines.
324 (setq alist gnus-cite-attribution-alist)
326 (setq entry (car alist)
330 skip (gnus-cite-find-prefix number)
331 face (cdr (assoc prefix face-alist)))
332 ;; Add attribution button.
334 (when (re-search-forward gnus-cite-attribution-suffix
335 (save-excursion (end-of-line 1) (point))
337 (gnus-article-add-button (match-beginning 1) (match-end 1)
338 'gnus-cite-toggle prefix))
339 ;; Highlight attribution line.
340 (gnus-cite-add-face number skip face)
341 (gnus-cite-add-face number skip gnus-cite-attribution-face))
342 ;; Loop through attribution lines.
343 (setq alist gnus-cite-loose-attribution-alist)
345 (setq entry (car alist)
348 skip (gnus-cite-find-prefix number))
349 (gnus-cite-add-face number skip gnus-cite-attribution-face)))))
351 (defun gnus-dissect-cited-text ()
352 "Dissect the article buffer looking for cited text."
354 (set-buffer gnus-article-buffer)
355 (gnus-cite-parse-maybe)
356 (let ((alist gnus-cite-prefix-alist)
357 prefix numbers number marks m)
358 ;; Loop through citation prefixes.
360 (setq numbers (pop alist)
361 prefix (pop numbers))
363 (setq number (pop numbers))
364 (goto-char (point-min))
365 (forward-line number)
366 (push (cons (point-marker) "") marks)
368 (= (1- number) (car numbers)))
369 (setq number (pop numbers)))
370 (goto-char (point-min))
371 (forward-line (1- number))
372 (push (cons (point-marker) prefix) marks)))
373 ;; Skip to the beginning of the body.
374 (goto-char (point-min))
375 (search-forward "\n\n" nil t)
376 (push (cons (point-marker) "") marks)
377 ;; Find the end of the body.
378 (goto-char (point-max))
379 (gnus-article-search-signature)
380 (push (cons (point-marker) "") marks)
382 (setq marks (sort marks (lambda (m1 m2) (< (car m1) (car m2)))))
383 (let ((omarks marks))
386 (if (= (caar omarks) (caadr omarks))
388 (unless (equal (cdar omarks) "")
389 (push (car omarks) marks))
390 (unless (equal (cdadr omarks) "")
391 (push (cadr omarks) marks))
392 (unless (and (equal (cdar omarks) "")
393 (equal (cdadr omarks) "")
395 (setq omarks (cdr omarks))))
396 (push (car omarks) marks))
397 (setq omarks (cdr omarks)))
399 (push (car omarks) marks))
400 (setq marks (setq m (nreverse marks)))
402 (if (and (equal (cdadr m) "")
403 (equal (cdar m) (cdaddr m))
404 (goto-char (caadr m))
406 (= (point) (caaddr m)))
411 (defun gnus-article-fill-cited-article (&optional force)
412 "Do word wrapping in the current article."
413 (interactive (list t))
415 (set-buffer gnus-article-buffer)
416 (let ((buffer-read-only nil)
417 (inhibit-point-motion-hooks t)
418 (marks (gnus-dissect-cited-text))
419 (adaptive-fill-mode nil))
423 (narrow-to-region (caar marks) (caadr marks))
424 (let ((adaptive-fill-regexp
425 (concat "^" (regexp-quote (cdar marks)) " *"))
426 (fill-prefix (cdar marks)))
427 (fill-region (point-min) (point-max)))
428 (set-marker (caar marks) nil)
429 (setq marks (cdr marks)))
431 (set-marker (caar marks) nil))
432 ;; All this information is now incorrect.
433 (setq gnus-cite-prefix-alist nil
434 gnus-cite-attribution-alist nil
435 gnus-cite-loose-prefix-alist nil
436 gnus-cite-loose-attribution-alist nil)))))
438 (defun gnus-article-hide-citation (&optional arg force)
439 "Toggle hiding of all cited text except attribution lines.
440 See the documentation for `gnus-article-highlight-citation'.
441 If given a negative prefix, always show; if given a positive prefix,
443 (interactive (append (gnus-article-hidden-arg) (list 'force)))
444 (setq gnus-cited-text-button-line-format-spec
445 (gnus-parse-format gnus-cited-text-button-line-format
446 gnus-cited-text-button-line-format-alist t))
448 (set-buffer gnus-article-buffer)
450 ((gnus-article-check-hidden-text 'cite arg)
452 ((gnus-article-text-type-exists-p 'cite)
453 (let ((buffer-read-only nil))
454 (gnus-article-hide-text-of-type 'cite)))
456 (let ((buffer-read-only nil)
457 (marks (gnus-dissect-cited-text))
458 (inhibit-point-motion-hooks t)
459 (props (nconc (list 'article-type 'cite)
460 gnus-hidden-properties))
465 (while (and marks (string= (cdar marks) ""))
466 (setq marks (cdr marks)))
468 (setq beg (caar marks)))
469 (while (and marks (not (string= (cdar marks) "")))
470 (setq marks (cdr marks)))
472 (setq end (caar marks)))
473 ;; Skip past lines we want to leave visible.
474 (when (and beg end gnus-cited-lines-visible)
476 (forward-line gnus-cited-lines-visible)
479 (setq beg (point-marker))))
481 (gnus-add-text-properties beg end props)
483 (unless (save-excursion (search-backward "\n\n" nil t))
488 (gnus-article-add-button
490 (progn (eval gnus-cited-text-button-line-format-spec) (point))
491 `gnus-article-toggle-cited-text (cons beg end))
493 'article-type 'annotation)
494 (set-marker beg (point)))))))))
496 (defun gnus-article-toggle-cited-text (region)
497 "Toggle hiding the text in REGION."
498 (let (buffer-read-only)
500 (if (text-property-any
501 (car region) (1- (cdr region))
502 (car gnus-hidden-properties) (cadr gnus-hidden-properties))
503 'remove-text-properties 'gnus-add-text-properties)
504 (car region) (cdr region) gnus-hidden-properties)))
506 (defun gnus-article-hide-citation-maybe (&optional arg force)
507 "Toggle hiding of cited text that has an attribution line.
508 If given a negative prefix, always show; if given a positive prefix,
510 This will do nothing unless at least `gnus-cite-hide-percentage'
511 percent and at least `gnus-cite-hide-absolute' lines of the body is
512 cited text with attributions. When called interactively, these two
513 variables are ignored.
514 See also the documentation for `gnus-article-highlight-citation'."
515 (interactive (append (gnus-article-hidden-arg) (list 'force)))
516 (unless (gnus-article-check-hidden-text 'cite arg)
518 (set-buffer gnus-article-buffer)
519 (gnus-cite-parse-maybe force)
520 (goto-char (point-min))
521 (search-forward "\n\n" nil t)
522 (let ((start (point))
523 (atts gnus-cite-attribution-alist)
524 (buffer-read-only nil)
525 (inhibit-point-motion-hooks t)
528 (goto-char (point-max))
529 (gnus-article-search-signature)
530 (setq total (count-lines start (point)))
532 (setq hiden (+ hiden (length (cdr (assoc (cdar atts)
533 gnus-cite-prefix-alist))))
536 (and (> (* 100 hiden) (* gnus-cite-hide-percentage total))
537 (> hiden gnus-cite-hide-absolute)))
538 (setq atts gnus-cite-attribution-alist)
540 (setq total (cdr (assoc (cdar atts) gnus-cite-prefix-alist))
543 (setq hiden (car total)
546 (unless (assq hiden gnus-cite-attribution-alist)
547 (gnus-add-text-properties
548 (point) (progn (forward-line 1) (point))
549 (nconc (list 'article-type 'cite)
550 gnus-hidden-properties))))))))))
552 (defun gnus-article-hide-citation-in-followups ()
553 "Hide cited text in non-root articles."
556 (set-buffer gnus-article-buffer)
557 (let ((article (cdr gnus-article-current)))
558 (unless (save-excursion
559 (set-buffer gnus-summary-buffer)
560 (gnus-article-displayed-root-p article))
561 (gnus-article-hide-citation)))))
563 ;;; Internal functions:
565 (defun gnus-cite-parse-maybe (&optional force)
566 ;; Parse if the buffer has changes since last time.
567 (if (equal gnus-cite-article gnus-article-current)
569 ;;Reset parser information.
570 (setq gnus-cite-prefix-alist nil
571 gnus-cite-attribution-alist nil
572 gnus-cite-loose-prefix-alist nil
573 gnus-cite-loose-attribution-alist nil)
574 ;; Parse if not too large.
576 gnus-cite-parse-max-size
577 (> (buffer-size) gnus-cite-parse-max-size))
579 (setq gnus-cite-article (cons (car gnus-article-current)
580 (cdr gnus-article-current)))
581 (gnus-cite-parse-wrapper))))
583 (defun gnus-cite-parse-wrapper ()
584 ;; Wrap chopped gnus-cite-parse
585 (goto-char (point-min))
586 (unless (search-forward "\n\n" nil t)
587 (goto-char (point-max)))
589 (gnus-cite-parse-attributions))
590 ;; Try to avoid check citation if there is no reason to believe
591 ;; that article has citations
592 (if (or gnus-cite-always-check
594 (re-search-backward gnus-cite-reply-regexp nil t))
595 gnus-cite-loose-attribution-alist)
596 (progn (save-excursion
599 (gnus-cite-connect-attributions)))))
601 (defun gnus-cite-parse ()
602 ;; Parse and connect citation prefixes and attribution lines.
604 ;; Parse current buffer searching for citation prefixes.
605 (let ((line (1+ (count-lines (point-min) (point))))
608 (goto-char (point-max))
609 (gnus-article-search-signature)
611 alist entry start begin end numbers prefix)
612 ;; Get all potential prefixes in `alist'.
613 (while (< (point) max)
616 end (progn (beginning-of-line 2) (point))
619 ;; Ignore standard Supercite attribution prefix.
620 (when (looking-at gnus-supercite-regexp)
622 (setq end (1+ (match-end 1)))
623 (setq end (1+ begin))))
624 ;; Ignore very long prefixes.
625 (when (> end (+ (point) gnus-cite-max-prefix))
626 (setq end (+ (point) gnus-cite-max-prefix)))
627 (while (re-search-forward gnus-cite-prefix-regexp (1- end) t)
629 (setq end (match-end 0)
630 prefix (buffer-substring begin end))
631 (gnus-set-text-properties 0 (length prefix) nil prefix)
632 (setq entry (assoc prefix alist))
634 (setcdr entry (cons line (cdr entry)))
635 (push (list prefix line) alist))
638 (setq line (1+ line)))
639 ;; We got all the potential prefixes. Now create
640 ;; `gnus-cite-prefix-alist' containing the oldest prefix for each
641 ;; line that appears at least gnus-cite-minimum-match-count
642 ;; times. First sort them by length. Longer is older.
643 (setq alist (sort alist (lambda (a b)
644 (> (length (car a)) (length (car b))))))
646 (setq entry (car alist)
650 (cond ((null numbers)
651 ;; No lines with this prefix that wasn't also part of
654 ((< (length numbers) gnus-cite-minimum-match-count)
655 ;; Too few lines with this prefix. We keep it a bit
656 ;; longer in case it is an exact match for an attribution
657 ;; line, but we don't remove the line from other
659 (push entry gnus-cite-prefix-alist))
662 gnus-cite-prefix-alist)
663 ;; Remove articles from other prefixes.
667 (setq current (car loop)
670 (gnus-set-difference (cdr current) numbers)))))))))
672 (defun gnus-cite-parse-attributions ()
674 ;; Parse attributions
675 (while (re-search-forward gnus-cite-attribution-suffix (point-max) t)
676 (let* ((start (match-beginning 0))
678 (wrote (count-lines (point-min) end))
679 (prefix (gnus-cite-find-prefix wrote))
680 ;; Check previous line for an attribution leader.
682 (beginning-of-line 1)
683 (when (looking-at gnus-supercite-secondary-regexp)
684 (buffer-substring (match-beginning 1)
688 (and (re-search-backward gnus-cite-attribution-prefix
690 (beginning-of-line 0)
693 (not (re-search-forward gnus-cite-attribution-suffix
695 (count-lines (point-min) (1+ (point)))))))
699 ;; don't add duplicates
700 (let ((al (buffer-substring (save-excursion (beginning-of-line 0)
703 (if (not (assoc al al-alist))
705 (push (list wrote in prefix tag)
706 gnus-cite-loose-attribution-alist)
707 (push (cons al t) al-alist))))))))
709 (defun gnus-cite-connect-attributions ()
710 ;; Connect attributions to citations
712 ;; No citations have been connected to attribution lines yet.
713 (setq gnus-cite-loose-prefix-alist (append gnus-cite-prefix-alist nil))
715 ;; Parse current buffer searching for attribution lines.
716 ;; Find exact supercite citations.
717 (gnus-cite-match-attributions 'small nil
721 (regexp-quote prefix) "[ \t]*"
722 (regexp-quote tag) ">"))))
723 ;; Find loose supercite citations after attributions.
724 (gnus-cite-match-attributions 'small t
730 ;; Find loose supercite citations anywhere.
731 (gnus-cite-match-attributions 'small nil
737 ;; Find nested citations after attributions.
738 (gnus-cite-match-attributions 'small-if-unique t
740 (concat "\\`" (regexp-quote prefix) ".+")))
741 ;; Find nested citations anywhere.
742 (gnus-cite-match-attributions 'small nil
744 (concat "\\`" (regexp-quote prefix) ".+")))
745 ;; Remove loose prefixes with too few lines.
746 (let ((alist gnus-cite-loose-prefix-alist)
749 (setq entry (car alist)
751 (when (< (length (cdr entry)) gnus-cite-minimum-match-count)
752 (setq gnus-cite-prefix-alist
753 (delq entry gnus-cite-prefix-alist)
754 gnus-cite-loose-prefix-alist
755 (delq entry gnus-cite-loose-prefix-alist)))))
756 ;; Find flat attributions.
757 (gnus-cite-match-attributions 'first t nil)
758 ;; Find any attributions (are we getting desperate yet?).
759 (gnus-cite-match-attributions 'first nil nil))
761 (defun gnus-cite-match-attributions (sort after fun)
762 ;; Match all loose attributions and citations (SORT AFTER FUN) .
764 ;; If SORT is `small', the citation with the shortest prefix will be
765 ;; used, if it is `first' the first prefix will be used, if it is
766 ;; `small-if-unique' the shortest prefix will be used if the
767 ;; attribution line does not share its own prefix with other
768 ;; loose attribution lines, otherwise the first prefix will be used.
770 ;; If AFTER is non-nil, only citations after the attribution line
771 ;; will be considered.
773 ;; If FUN is non-nil, it will be called with the arguments (WROTE
774 ;; PREFIX TAG) and expected to return a regular expression. Only
775 ;; citations whose prefix matches the regular expression will be
778 ;; WROTE is the attribution line number.
779 ;; PREFIX is the attribution line prefix.
780 ;; TAG is the Supercite tag on the attribution line.
781 (let ((atts gnus-cite-loose-attribution-alist)
783 att wrote in prefix tag regexp limit smallest best size)
791 regexp (if fun (funcall fun prefix tag) "")
792 size (cond ((eq sort 'small) t)
793 ((eq sort 'first) nil)
794 (t (< (length (gnus-cite-find-loose prefix)) 2)))
795 limit (if after wrote -1)
798 (let ((cites gnus-cite-loose-prefix-alist)
799 cite candidate numbers first compare)
801 (setq cite (car cites)
805 first (apply 'min numbers)
806 compare (if size (length candidate) first))
809 (string-match regexp candidate)
815 (setq gnus-cite-loose-attribution-alist
816 (delq att gnus-cite-loose-attribution-alist))
817 (push (cons wrote (car best)) gnus-cite-attribution-alist)
819 (push (cons in (car best)) gnus-cite-attribution-alist))
820 (when (memq best gnus-cite-loose-prefix-alist)
821 (let ((loop gnus-cite-prefix-alist)
824 (setq gnus-cite-loose-prefix-alist
825 (delq best gnus-cite-loose-prefix-alist))
827 (setq current (car loop)
829 (if (eq current best)
831 (setcdr current (gnus-set-difference (cdr current) numbers))
832 (when (null (cdr current))
833 (setq gnus-cite-loose-prefix-alist
834 (delq current gnus-cite-loose-prefix-alist)
835 atts (delq current atts)))))))))))
837 (defun gnus-cite-find-loose (prefix)
838 ;; Return a list of loose attribution lines prefixed by PREFIX.
839 (let* ((atts gnus-cite-loose-attribution-alist)
845 (when (string-equal (gnus-cite-find-prefix line) prefix)
849 (defun gnus-cite-add-face (number prefix face)
850 ;; At line NUMBER, ignore PREFIX and add FACE to the rest of the line.
852 (let ((inhibit-point-motion-hooks t)
855 (unless (eobp);; Sometimes things become confused.
856 (forward-char (length prefix))
857 (skip-chars-forward " \t")
860 (skip-chars-backward " \t")
863 (gnus-overlay-put (gnus-make-overlay from to) 'face face))))))
865 (defun gnus-cite-toggle (prefix)
867 (set-buffer gnus-article-buffer)
868 (let ((buffer-read-only nil)
869 (numbers (cdr (assoc prefix gnus-cite-prefix-alist)))
870 (inhibit-point-motion-hooks t)
873 (setq number (car numbers)
874 numbers (cdr numbers))
876 (cond ((get-text-property (point) 'invisible)
877 (remove-text-properties (point) (progn (forward-line 1) (point))
878 gnus-hidden-properties))
879 ((assq number gnus-cite-attribution-alist))
881 (gnus-add-text-properties
882 (point) (progn (forward-line 1) (point))
883 (nconc (list 'article-type 'cite)
884 gnus-hidden-properties))))))))
886 (defun gnus-cite-find-prefix (line)
887 ;; Return citation prefix for LINE.
888 (let ((alist gnus-cite-prefix-alist)
892 (setq entry (car alist)
894 (when (memq line (cdr entry))
895 (setq prefix (car entry))))
898 (gnus-add-shutdown 'gnus-cache-close 'gnus)
900 (defun gnus-cache-close ()
901 (setq gnus-cite-prefix-alist nil))
907 ;;; gnus-cite.el ends here