;;; 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
(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)
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)
(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)
: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)
'(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.
;;; Internal Variables:
(defvar gnus-cite-article nil)
+(defvar gnus-cite-overlay-list nil)
(defvar gnus-cite-prefix-alist nil)
;; Alist of citation prefixes.
(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))
(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)))))))))
(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))
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)
(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
;; 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))
(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)
(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)