*** empty log message ***
[gnus] / lisp / gnus-cite.el
index 357f784..51a927d 100644 (file)
 
 ;;; Code:
 
+(require 'gnus-load)
 (require 'gnus)
-(require 'gnus-msg)
-(require 'gnus-ems)
-(eval-when-compile (require 'cl))
-
-(eval-and-compile
-  (autoload 'gnus-article-add-button "gnus-vis"))
+(require 'gnus-art)
+(require 'gnus-range)
 
 ;;; Customization:
 
@@ -65,21 +62,6 @@ The first regexp group should match the Supercite attribution.")
 (defvar gnus-cite-minimum-match-count 2
   "Minimum number of identical prefixes before we believe it's a citation.")
 
-;see gnus-cus.el
-;(defvar gnus-cite-face-list 
-;  (if (eq gnus-display-type 'color)
-;      (if (eq gnus-background-mode 'dark) 'light 'dark)
-;    '(italic))
-;  "Faces used for displaying different citations.
-;It is either a list of face names, or one of the following special
-;values:
-
-;dark: Create faces from `gnus-face-dark-name-list'.
-;light: Create faces from `gnus-face-light-name-list'.
-
-;The variable `gnus-make-foreground' determines whether the created
-;faces change the foreground or the background colors.")
-
 (defvar gnus-cite-attribution-prefix "in article\\|in <"
   "Regexp matching the beginning of an attribution line.")
 
@@ -88,32 +70,30 @@ The first regexp group should match the Supercite attribution.")
   "Regexp matching the end of an attribution line.
 The text matching the first grouping will be used as a button.")
 
-;see gnus-cus.el
-;(defvar gnus-cite-attribution-face 'underline
-;  "Face used for attribution lines.
-;It is merged with the face for the cited text belonging to the attribution.")
-
-;see gnus-cus.el
-;(defvar gnus-cite-hide-percentage 50
-;  "Only hide cited text if it is larger than this percent of the body.")
-
-;see gnus-cus.el
-;(defvar gnus-cite-hide-absolute 10
-;  "Only hide cited text if there is at least this number of cited lines.")
-
-;see gnus-cus.el
-;(defvar gnus-face-light-name-list
-;  '("light blue" "light cyan" "light yellow" "light pink"
-;    "pale green" "beige" "orange" "magenta" "violet" "medium purple"
-;    "turquoise")
-;  "Names of light colors.")
-
-;see gnus-cus.el
-;(defvar gnus-face-dark-name-list
-;  '("dark salmon" "firebrick"
-;    "dark green" "dark orange" "dark khaki" "dark violet"
-;    "dark turquoise")
-;  "Names of dark colors.")
+(defvar gnus-cite-attribution-face 'underline
+  "Face used for attribution lines.
+It is merged with the face for the cited text belonging to the attribution.")
+
+(defvar gnus-cite-face-list 
+  (cond ((not (eq gnus-display-type 'color))
+        '(italic))
+       ((eq gnus-background-mode 'dark)
+        (mapcar 'gnus-make-face 
+                gnus-face-light-name-list))
+       (t 
+        (mapcar 'gnus-make-face 
+                gnus-face-dark-name-list)))
+  "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.
+This should make it easier to see who wrote what.")
+
+(defvar gnus-cite-hide-percentage 50
+  "Only hide excess citation if above this percentage of the body.")
+
+(defvar gnus-cite-hide-absolute 10
+  "Only hide excess citation if above this number of lines in the body.")
 
 ;;; Internal Variables:
 
@@ -245,7 +225,7 @@ Lines matching `gnus-cite-attribution-suffix' and perhaps
       (search-forward "\n\n" nil t)
       (push (cons (point-marker) "") marks)
       (goto-char (point-max))
-      (re-search-backward gnus-signature-separator nil t)
+      (article-search-signature)
       (push (cons (point-marker) "") marks)
       (setq marks (sort marks (lambda (m1 m2) (< (car m1) (car m2)))))
       (let* ((omarks marks))
@@ -273,7 +253,6 @@ Lines matching `gnus-cite-attribution-suffix' and perhaps
            (setq m (cdr m))))
        marks))))
            
-
 (defun gnus-article-fill-cited-article (&optional force)
   "Do word wrapping in the current article."
   (interactive (list t))
@@ -301,17 +280,23 @@ Lines matching `gnus-cite-attribution-suffix' and perhaps
 See the documentation for `gnus-article-highlight-citation'.
 If given a negative prefix, always show; if given a positive prefix,
 always hide."
-  (interactive (append (gnus-hidden-arg) (list 'force)))
+  (interactive (append (article-hidden-arg) (list 'force)))
   (setq gnus-cited-text-button-line-format-spec 
        (gnus-parse-format gnus-cited-text-button-line-format 
                           gnus-cited-text-button-line-format-alist t))
-  (unless (gnus-article-check-hidden-text 'cite arg)
-    (save-excursion
-      (set-buffer gnus-article-buffer)
+  (save-excursion
+    (set-buffer gnus-article-buffer)
+    (cond
+     ((article-check-hidden-text 'cite arg)
+      t)
+     ((article-text-type-exists-p 'cite)
+      (let ((buffer-read-only nil))
+       (article-hide-text-of-type 'cite)))
+     (t
       (let ((buffer-read-only nil)
            (marks (gnus-dissect-cited-text))
            (inhibit-point-motion-hooks t)
-           (props (nconc (list 'gnus-type 'cite)
+           (props (nconc (list 'article-type 'cite)
                          gnus-hidden-properties))
            beg end)
        (while marks
@@ -326,10 +311,10 @@ always hide."
          (when marks
            (setq end (caar marks)))
          ;; Skip past lines we want to leave visible.
-         (when (and beg gnus-cited-lines-visible)
+         (when (and beg end gnus-cited-lines-visible)
            (goto-char beg)
            (forward-line gnus-cited-lines-visible)
-           (if (> (point) end)
+           (if (>= (point) end)
                (setq beg nil)
              (setq beg (point-marker))))
          (when (and beg end)
@@ -337,11 +322,16 @@ always hide."
            (goto-char beg)
            (unless (save-excursion (search-backward "\n\n" nil t))
              (insert "\n"))
-           (gnus-article-add-button
+           (put-text-property
             (point)
-            (progn (eval gnus-cited-text-button-line-format-spec) (point))
-            `gnus-article-toggle-cited-text (cons beg end))
-           (set-marker beg (point))))))))
+            (progn
+              (gnus-article-add-button
+               (point)
+               (progn (eval gnus-cited-text-button-line-format-spec) (point))
+               `gnus-article-toggle-cited-text (cons beg end))
+              (point))
+            'article-type 'annotation)
+           (set-marker beg (point)))))))))
 
 (defun gnus-article-toggle-cited-text (region)
   "Toggle hiding the text in REGION."
@@ -362,8 +352,8 @@ 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-hidden-arg) (list 'force)))
-  (unless (gnus-article-check-hidden-text 'cite arg)
+  (interactive (append (article-hidden-arg) (list 'force)))
+  (unless (article-check-hidden-text 'cite arg)
     (save-excursion
       (set-buffer gnus-article-buffer)
       (gnus-cite-parse-maybe force)
@@ -376,7 +366,7 @@ See also the documentation for `gnus-article-highlight-citation'."
            (hiden 0)
            total)
        (goto-char (point-max))
-       (re-search-backward gnus-signature-separator nil t)
+       (article-search-signature)
        (setq total (count-lines start (point)))
        (while atts
          (setq hiden (+ hiden (length (cdr (assoc (cdar atts)
@@ -397,7 +387,7 @@ See also the documentation for `gnus-article-highlight-citation'."
                  (or (assq hiden gnus-cite-attribution-alist)
                      (gnus-add-text-properties 
                       (point) (progn (forward-line 1) (point))
-                      (nconc (list 'gnus-type 'cite)
+                      (nconc (list 'article-type 'cite)
                              gnus-hidden-properties)))))))))))
 
 (defun gnus-article-hide-citation-in-followups ()
@@ -442,7 +432,7 @@ See also the documentation for `gnus-article-highlight-citation'."
        (case-fold-search t)
        (max (save-excursion
               (goto-char (point-max))
-              (re-search-backward gnus-signature-separator nil t)
+              (article-search-signature)
               (point)))
        alist entry start begin end numbers prefix)
     ;; Get all potential prefixes in `alist'.
@@ -475,7 +465,7 @@ See also the documentation for `gnus-article-highlight-citation'."
     ;; We got all the potential prefixes.  Now create
     ;; `gnus-cite-prefix-alist' containing the oldest prefix for each
     ;; line that appears at least gnus-cite-minimum-match-count
-    ;; times. First sort them by length.  Longer is older.
+    ;; times.  First sort them by length.  Longer is older.
     (setq alist (sort alist (lambda (a b)
                              (> (length (car a)) (length (car b))))))
     (while alist
@@ -677,7 +667,7 @@ See also the documentation for `gnus-article-highlight-citation'."
     (let ((inhibit-point-motion-hooks t)
          from to)
       (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))
@@ -705,8 +695,8 @@ See also the documentation for `gnus-article-highlight-citation'."
              (t
               (gnus-add-text-properties 
                (point) (progn (forward-line 1) (point))
-                (nconc (list 'gnus-type 'cite)
-                       gnus-hidden-properties))))))))
+               (nconc (list 'article-type 'cite)
+                      gnus-hidden-properties))))))))
 
 (defun gnus-cite-find-prefix (line)
   ;; Return citation prefix for LINE.
@@ -720,6 +710,11 @@ 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))
+
 (gnus-ems-redefine)
 
 (provide 'gnus-cite)