(message-mode-map): Now "\C-c\C-f\C-r" inserts Mail-Reply-To:.
[elisp/gnus.git-] / lisp / gnus-cite.el
index 2a1eb4f..5dd0f89 100644 (file)
@@ -1,5 +1,5 @@
 ;;; gnus-cite.el --- parse citations in articles for Gnus
-;; Copyright (C) 1995,96,97 Free Software Foundation, Inc.
+;; Copyright (C) 1995,96,97,98 Free Software Foundation, Inc.
 
 ;; Author: Per Abrahamsen <abraham@iesd.auc.dk>
 ;; Keywords: news, mail
@@ -41,7 +41,7 @@
 
 (defcustom gnus-cite-reply-regexp
   "^\\(Subject: Re\\|In-Reply-To\\|References\\):"
-  "If headers match this regexp it is reasonable to believe that
+  "*If headers match this regexp it is reasonable to believe that
 article has citations."
   :group 'gnus-cite
   :type 'string)
@@ -71,8 +71,8 @@ Set it to nil to parse all articles."
                 integer))
 
 (defcustom gnus-cite-prefix-regexp
-    "^[]>|:}+ ]*[]>|:}+]\\(.*>\\)?\\|^.*>"
-  "Regexp matching the longest possible citation prefix on a line."
+  "^[]>|:}+ ]*[]>|:}+]\\(.*>\\)?\\|^.*>"
+  "*Regexp matching the longest possible citation prefix on a line."
   :group 'gnus-cite
   :type 'regexp)
 
@@ -84,7 +84,7 @@ Set it to nil to parse all articles."
 (defcustom gnus-supercite-regexp
   (concat "^\\(" gnus-cite-prefix-regexp "\\)? *"
          ">>>>> +\"\\([^\"\n]+\\)\" +==")
-  "Regexp matching normal Supercite attribution lines.
+  "*Regexp matching normal Supercite attribution lines.
 The first grouping must match prefixes added by other packages."
   :group 'gnus-cite
   :type 'regexp)
@@ -101,14 +101,14 @@ The first regexp group should match the Supercite attribution."
   :type 'integer)
 
 (defcustom gnus-cite-attribution-prefix 
-  "in article\\|in <\\|On \\(Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\|Sun\\),"
-  "Regexp matching the beginning of an attribution line."
+  "In article\\|in <\\|On \\(Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\|Sun\\),"
+  "*Regexp matching the beginning of an attribution line."
   :group 'gnus-cite
   :type 'regexp)
 
 (defcustom gnus-cite-attribution-suffix
   "\\(\\(wrote\\|writes\\|said\\|says\\|>\\)\\(:\\|\\.\\.\\.\\)\\)[ \t]*$"
-  "Regexp matching the end of an attribution line.
+  "*Regexp matching the end of an attribution line.
 The text matching the first grouping will be used as a button."
   :group 'gnus-cite
   :type 'regexp)
@@ -237,7 +237,7 @@ It is merged with the face for the cited text belonging to the attribution."
   '(gnus-cite-face-1 gnus-cite-face-2 gnus-cite-face-3 gnus-cite-face-4
     gnus-cite-face-5 gnus-cite-face-6 gnus-cite-face-7 gnus-cite-face-8
     gnus-cite-face-9 gnus-cite-face-10 gnus-cite-face-11)
-  "List of faces used for highlighting citations.
+  "*List of faces used for highlighting citations.
 
 When there are citations from multiple articles in the same message,
 Gnus will try to give each citation from each article its own face.
@@ -258,6 +258,7 @@ This should make it easier to see who wrote what."
 ;;; Internal Variables:
 
 (defvar gnus-cite-article nil)
+(defvar gnus-cite-overlay-list nil)
 
 (defvar gnus-cite-prefix-alist nil)
 ;; Alist of citation prefixes.
@@ -484,6 +485,10 @@ always hide."
                (setq beg nil)
              (setq beg (point-marker))))
          (when (and beg end)
+           ;; We use markers for the end-points to facilitate later
+           ;; wrapping and mangling of text.
+           (setq beg (set-marker (make-marker) beg)
+                 end (set-marker (make-marker) end))
            (gnus-add-text-properties beg end props)
            (goto-char beg)
            (unless (save-excursion (search-backward "\n\n" nil t))
@@ -494,7 +499,8 @@ always hide."
               (gnus-article-add-button
                (point)
                (progn (eval gnus-cited-text-button-line-format-spec) (point))
-               `gnus-article-toggle-cited-text (cons beg end))
+               `gnus-article-toggle-cited-text
+               (cons beg end))
               (point))
             'article-type 'annotation)
            (set-marker beg (point)))))))))
@@ -502,7 +508,7 @@ always hide."
 (defun gnus-article-toggle-cited-text (region)
   "Toggle hiding the text in REGION."
   (let (buffer-read-only)
-    (funcall
+    (funcall 
      (if (text-property-any
          (car region) (1- (cdr region))
          (car gnus-hidden-properties) (cadr gnus-hidden-properties))
@@ -518,7 +524,7 @@ percent and at least `gnus-cite-hide-absolute' lines of the body is
 cited text with attributions.  When called interactively, these two
 variables are ignored.
 See also the documentation for `gnus-article-highlight-citation'."
-  (interactive (append (gnus-article-hidden-arg) (list 'force)))
+  (interactive (append (gnus-article-hidden-arg) '(force)))
   (unless (gnus-article-check-hidden-text 'cite arg)
     (save-excursion
       (set-buffer gnus-article-buffer)
@@ -570,13 +576,17 @@ See also the documentation for `gnus-article-highlight-citation'."
 
 (defun gnus-cite-parse-maybe (&optional force)
   ;; Parse if the buffer has changes since last time.
-  (if (equal gnus-cite-article gnus-article-current)
+  (if (and (not force)
+          (equal gnus-cite-article gnus-article-current))
       ()
+    (gnus-cite-localize)
     ;;Reset parser information.
     (setq gnus-cite-prefix-alist nil
          gnus-cite-attribution-alist nil
          gnus-cite-loose-prefix-alist nil
          gnus-cite-loose-attribution-alist nil)
+    (while gnus-cite-overlay-list
+      (gnus-delete-overlay (pop gnus-cite-overlay-list)))
     ;; Parse if not too large.
     (if (and (not force)
             gnus-cite-parse-max-size
@@ -856,9 +866,9 @@ See also the documentation for `gnus-article-highlight-citation'."
   ;; At line NUMBER, ignore PREFIX and add FACE to the rest of the line.
   (when face
     (let ((inhibit-point-motion-hooks t)
-         from to)
+         from to overlay)
       (goto-line number)
-      (unless (eobp);; Sometimes things become confused.
+      (unless (eobp)                   ; Sometimes things become confused.
        (forward-char (length prefix))
        (skip-chars-forward " \t")
        (setq from (point))
@@ -866,11 +876,14 @@ See also the documentation for `gnus-article-highlight-citation'."
        (skip-chars-backward " \t")
        (setq to (point))
        (when (< from to)
-         (gnus-overlay-put (gnus-make-overlay from to) 'face face))))))
+         (push (setq overlay (gnus-make-overlay from to))
+               gnus-cite-overlay-list)
+         (gnus-overlay-put overlay 'face face))))))
 
 (defun gnus-cite-toggle (prefix)
   (save-excursion
     (set-buffer gnus-article-buffer)
+    (gnus-cite-parse-maybe)
     (let ((buffer-read-only nil)
          (numbers (cdr (assoc prefix gnus-cite-prefix-alist)))
          (inhibit-point-motion-hooks t)
@@ -901,10 +914,14 @@ See also the documentation for `gnus-article-highlight-citation'."
        (setq prefix (car entry))))
     prefix))
 
-(gnus-add-shutdown 'gnus-cache-close 'gnus)
-
-(defun gnus-cache-close ()
-  (setq gnus-cite-prefix-alist nil))
+(defun gnus-cite-localize ()
+  "Make the citation variables local to the article buffer."
+  (let ((vars '(gnus-cite-article
+               gnus-cite-overlay-list gnus-cite-prefix-alist
+               gnus-cite-attribution-alist gnus-cite-loose-prefix-alist
+               gnus-cite-loose-attribution-alist)))
+    (while vars
+      (make-local-variable (pop vars)))))
 
 (gnus-ems-redefine)