*** empty log message ***
[gnus] / lisp / gnus-cite.el
index c9f9f23..51a927d 100644 (file)
@@ -30,9 +30,6 @@
 (require 'gnus-art)
 (require 'gnus-range)
 
-(eval-and-compile
-  (autoload 'gnus-article-add-button "gnus-vis"))
-
 ;;; Customization:
 
 (defvar gnus-cited-text-button-line-format "%(%{[...]%}%)\n"
@@ -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 article-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))
@@ -304,14 +284,20 @@ always hide."
   (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 (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)
-                         article-hidden-properties))
+           (props (nconc (list 'article-type 'cite)
+                         gnus-hidden-properties))
            beg end)
        (while marks
          (setq beg nil
@@ -336,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."
@@ -348,9 +339,9 @@ always hide."
     (funcall
      (if (text-property-any
          (car region) (1- (cdr region))
-         (car article-hidden-properties) (cadr article-hidden-properties))
+         (car gnus-hidden-properties) (cadr gnus-hidden-properties))
         'remove-text-properties 'gnus-add-text-properties)
-     (car region) (cdr region) article-hidden-properties)))
+     (car region) (cdr region) gnus-hidden-properties)))
 
 (defun gnus-article-hide-citation-maybe (&optional arg force)
   "Toggle hiding of cited text that has an attribution line.
@@ -375,7 +366,7 @@ See also the documentation for `gnus-article-highlight-citation'."
            (hiden 0)
            total)
        (goto-char (point-max))
-       (re-search-backward article-signature-separator nil t)
+       (article-search-signature)
        (setq total (count-lines start (point)))
        (while atts
          (setq hiden (+ hiden (length (cdr (assoc (cdar atts)
@@ -396,8 +387,8 @@ 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)
-                             article-hidden-properties)))))))))))
+                      (nconc (list 'article-type 'cite)
+                             gnus-hidden-properties)))))))))))
 
 (defun gnus-article-hide-citation-in-followups ()
   "Hide cited text in non-root articles."
@@ -441,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 article-signature-separator nil t)
+              (article-search-signature)
               (point)))
        alist entry start begin end numbers prefix)
     ;; Get all potential prefixes in `alist'.
@@ -474,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
@@ -676,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))
@@ -699,13 +690,13 @@ See also the documentation for `gnus-article-highlight-citation'."
        (goto-line number)
        (cond ((get-text-property (point) 'invisible)
               (remove-text-properties (point) (progn (forward-line 1) (point))
-                                      article-hidden-properties))
+                                      gnus-hidden-properties))
              ((assq number gnus-cite-attribution-alist))
              (t
               (gnus-add-text-properties 
                (point) (progn (forward-line 1) (point))
-                (nconc (list 'gnus-type 'cite)
-                       article-hidden-properties))))))))
+               (nconc (list 'article-type 'cite)
+                      gnus-hidden-properties))))))))
 
 (defun gnus-cite-find-prefix (line)
   ;; Return citation prefix for LINE.