annotate lisp/gnus-cite.el @ 23192:1ea9db09a678

(checkdoc-buffer-label): New function. (checkdoc-start-section, checkdoc-error): Use `checkdoc-buffer-label'. (checkdoc-this-string-valid-engine): Permit ? as terminating punctuation for first line sentence breaking. (checkdoc-this-string-valid): When converting a comment into a doc string, make sure " chars are \". (checkdoc-sentencespace-region-engine): Only do double space check if based on the variable `sentence-end-double-space'
author Eric M. Ludlam <zappo@gnu.org>
date Sat, 05 Sep 1998 13:46:23 +0000
parents 530d0d516a42
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
1 ;;; gnus-cite.el --- parse citations in articles for Gnus
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
2 ;; Copyright (C) 1995,96 Free Software Foundation, Inc.
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
3
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
4 ;; Author: Per Abrahamsen <abraham@iesd.auc.dk>
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
5 ;; Keywords: news, mail
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
6
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
8
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
12 ;; any later version.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
13
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
17 ;; GNU General Public License for more details.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
18
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
22 ;; Boston, MA 02111-1307, USA.
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
23
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
24 ;;; Commentary:
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
25
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
26 ;;; Code:
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
27
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
28 (require 'gnus)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
29 (require 'gnus-msg)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
30 (require 'gnus-ems)
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
31 (eval-when-compile (require 'cl))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
32
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
33 (eval-and-compile
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
34 (autoload 'gnus-article-add-button "gnus-vis"))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
35
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
36 ;;; Customization:
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
37
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
38 (defvar gnus-cited-text-button-line-format "%(%{[...]%}%)\n"
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
39 "Format of cited text buttons.")
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
40
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
41 (defvar gnus-cited-lines-visible nil
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
42 "The number of lines of hidden cited text to remain visible.")
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
43
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
44 (defvar gnus-cite-parse-max-size 25000
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
45 "Maximum article size (in bytes) where parsing citations is allowed.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
46 Set it to nil to parse all articles.")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
47
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
48 (defvar gnus-cite-prefix-regexp
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
49 "^[]>|:}+ ]*[]>|:}+]\\(.*>\\)?\\|^.*>"
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
50 "Regexp matching the longest possible citation prefix on a line.")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
51
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
52 (defvar gnus-cite-max-prefix 20
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
53 "Maximum possible length for a citation prefix.")
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
54
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
55 (defvar gnus-supercite-regexp
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
56 (concat "^\\(" gnus-cite-prefix-regexp "\\)? *"
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
57 ">>>>> +\"\\([^\"\n]+\\)\" +==")
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
58 "Regexp matching normal Supercite attribution lines.
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
59 The first grouping must match prefixes added by other packages.")
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
60
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
61 (defvar gnus-supercite-secondary-regexp "^.*\"\\([^\"\n]+\\)\" +=="
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
62 "Regexp matching mangled Supercite attribution lines.
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
63 The first regexp group should match the Supercite attribution.")
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
64
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
65 (defvar gnus-cite-minimum-match-count 2
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
66 "Minimum number of identical prefixes before we believe it's a citation.")
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
67
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
68 ;see gnus-cus.el
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
69 ;(defvar gnus-cite-face-list
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
70 ; (if (eq gnus-display-type 'color)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
71 ; (if (eq gnus-background-mode 'dark) 'light 'dark)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
72 ; '(italic))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
73 ; "Faces used for displaying different citations.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
74 ;It is either a list of face names, or one of the following special
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
75 ;values:
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
76
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
77 ;dark: Create faces from `gnus-face-dark-name-list'.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
78 ;light: Create faces from `gnus-face-light-name-list'.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
79
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
80 ;The variable `gnus-make-foreground' determines whether the created
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
81 ;faces change the foreground or the background colors.")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
82
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
83 (defvar gnus-cite-attribution-prefix "in article\\|in <"
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
84 "Regexp matching the beginning of an attribution line.")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
85
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
86 (defvar gnus-cite-attribution-suffix
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
87 "\\(wrote\\|writes\\|said\\|says\\):[ \t]*$"
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
88 "Regexp matching the end of an attribution line.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
89 The text matching the first grouping will be used as a button.")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
90
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
91 ;see gnus-cus.el
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
92 ;(defvar gnus-cite-attribution-face 'underline
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
93 ; "Face used for attribution lines.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
94 ;It is merged with the face for the cited text belonging to the attribution.")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
95
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
96 ;see gnus-cus.el
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
97 ;(defvar gnus-cite-hide-percentage 50
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
98 ; "Only hide cited text if it is larger than this percent of the body.")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
99
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
100 ;see gnus-cus.el
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
101 ;(defvar gnus-cite-hide-absolute 10
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
102 ; "Only hide cited text if there is at least this number of cited lines.")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
103
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
104 ;see gnus-cus.el
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
105 ;(defvar gnus-face-light-name-list
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
106 ; '("light blue" "light cyan" "light yellow" "light pink"
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
107 ; "pale green" "beige" "orange" "magenta" "violet" "medium purple"
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
108 ; "turquoise")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
109 ; "Names of light colors.")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
110
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
111 ;see gnus-cus.el
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
112 ;(defvar gnus-face-dark-name-list
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
113 ; '("dark salmon" "firebrick"
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
114 ; "dark green" "dark orange" "dark khaki" "dark violet"
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
115 ; "dark turquoise")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
116 ; "Names of dark colors.")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
117
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
118 ;;; Internal Variables:
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
119
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
120 (defvar gnus-cite-article nil)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
121
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
122 (defvar gnus-cite-prefix-alist nil)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
123 ;; Alist of citation prefixes.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
124 ;; The cdr is a list of lines with that prefix.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
125
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
126 (defvar gnus-cite-attribution-alist nil)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
127 ;; Alist of attribution lines.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
128 ;; The car is a line number.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
129 ;; The cdr is the prefix for the citation started by that line.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
130
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
131 (defvar gnus-cite-loose-prefix-alist nil)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
132 ;; Alist of citation prefixes that have no matching attribution.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
133 ;; The cdr is a list of lines with that prefix.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
134
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
135 (defvar gnus-cite-loose-attribution-alist nil)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
136 ;; Alist of attribution lines that have no matching citation.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
137 ;; Each member has the form (WROTE IN PREFIX TAG), where
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
138 ;; WROTE: is the attribution line number
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
139 ;; IN: is the line number of the previous line if part of the same attribution,
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
140 ;; PREFIX: Is the citation prefix of the attribution line(s), and
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
141 ;; TAG: Is a Supercite tag, if any.
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
142
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
143 (defvar gnus-cited-text-button-line-format-alist
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
144 `((?b beg ?d)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
145 (?e end ?d)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
146 (?l (- end beg) ?d)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
147 (defvar gnus-cited-text-button-line-format-spec nil)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
148
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
149 ;;; Commands:
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
150
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
151 (defun gnus-article-highlight-citation (&optional force)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
152 "Highlight cited text.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
153 Each citation in the article will be highlighted with a different face.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
154 The faces are taken from `gnus-cite-face-list'.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
155 Attribution lines are highlighted with the same face as the
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
156 corresponding citation merged with `gnus-cite-attribution-face'.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
157
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
158 Text is considered cited if at least `gnus-cite-minimum-match-count'
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
159 lines matches `gnus-cite-prefix-regexp' with the same prefix.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
160
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
161 Lines matching `gnus-cite-attribution-suffix' and perhaps
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
162 `gnus-cite-attribution-prefix' are considered attribution lines."
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
163 (interactive (list 'force))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
164 ;; Create dark or light faces if necessary.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
165 (cond ((eq gnus-cite-face-list 'light)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
166 (setq gnus-cite-face-list
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
167 (mapcar 'gnus-make-face gnus-face-light-name-list)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
168 ((eq gnus-cite-face-list 'dark)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
169 (setq gnus-cite-face-list
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
170 (mapcar 'gnus-make-face gnus-face-dark-name-list))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
171 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
172 (set-buffer gnus-article-buffer)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
173 (gnus-cite-parse-maybe force)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
174 (let ((buffer-read-only nil)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
175 (alist gnus-cite-prefix-alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
176 (faces gnus-cite-face-list)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
177 (inhibit-point-motion-hooks t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
178 face entry prefix skip numbers number face-alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
179 ;; Loop through citation prefixes.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
180 (while alist
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
181 (setq entry (car alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
182 alist (cdr alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
183 prefix (car entry)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
184 numbers (cdr entry)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
185 face (car faces)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
186 faces (or (cdr faces) gnus-cite-face-list)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
187 face-alist (cons (cons prefix face) face-alist))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
188 (while numbers
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
189 (setq number (car numbers)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
190 numbers (cdr numbers))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
191 (and (not (assq number gnus-cite-attribution-alist))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
192 (not (assq number gnus-cite-loose-attribution-alist))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
193 (gnus-cite-add-face number prefix face))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
194 ;; Loop through attribution lines.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
195 (setq alist gnus-cite-attribution-alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
196 (while alist
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
197 (setq entry (car alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
198 alist (cdr alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
199 number (car entry)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
200 prefix (cdr entry)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
201 skip (gnus-cite-find-prefix number)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
202 face (cdr (assoc prefix face-alist)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
203 ;; Add attribution button.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
204 (goto-line number)
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
205 (if (re-search-forward gnus-cite-attribution-suffix
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
206 (save-excursion (end-of-line 1) (point))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
207 t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
208 (gnus-article-add-button (match-beginning 1) (match-end 1)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
209 'gnus-cite-toggle prefix))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
210 ;; Highlight attribution line.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
211 (gnus-cite-add-face number skip face)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
212 (gnus-cite-add-face number skip gnus-cite-attribution-face))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
213 ;; Loop through attribution lines.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
214 (setq alist gnus-cite-loose-attribution-alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
215 (while alist
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
216 (setq entry (car alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
217 alist (cdr alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
218 number (car entry)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
219 skip (gnus-cite-find-prefix number))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
220 (gnus-cite-add-face number skip gnus-cite-attribution-face)))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
221
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
222 (defun gnus-dissect-cited-text ()
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
223 "Dissect the article buffer looking for cited text."
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
224 (save-excursion
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
225 (set-buffer gnus-article-buffer)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
226 (gnus-cite-parse-maybe)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
227 (let ((alist gnus-cite-prefix-alist)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
228 prefix numbers number marks m)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
229 ;; Loop through citation prefixes.
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
230 (while alist
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
231 (setq numbers (pop alist)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
232 prefix (pop numbers))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
233 (while numbers
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
234 (setq number (pop numbers))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
235 (goto-char (point-min))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
236 (forward-line number)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
237 (push (cons (point-marker) "") marks)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
238 (while (and numbers
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
239 (= (1- number) (car numbers)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
240 (setq number (pop numbers)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
241 (goto-char (point-min))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
242 (forward-line (1- number))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
243 (push (cons (point-marker) prefix) marks)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
244 (goto-char (point-min))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
245 (search-forward "\n\n" nil t)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
246 (push (cons (point-marker) "") marks)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
247 (goto-char (point-max))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
248 (re-search-backward gnus-signature-separator nil t)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
249 (push (cons (point-marker) "") marks)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
250 (setq marks (sort marks (lambda (m1 m2) (< (car m1) (car m2)))))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
251 (let* ((omarks marks))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
252 (setq marks nil)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
253 (while (cdr omarks)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
254 (if (= (caar omarks) (caadr omarks))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
255 (progn
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
256 (unless (equal (cdar omarks) "")
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
257 (push (car omarks) marks))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
258 (unless (equal (cdadr omarks) "")
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
259 (push (cadr omarks) marks))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
260 (setq omarks (cdr omarks)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
261 (push (car omarks) marks))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
262 (setq omarks (cdr omarks)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
263 (when (car omarks)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
264 (push (car omarks) marks))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
265 (setq marks (setq m (nreverse marks)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
266 (while (cddr m)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
267 (if (and (equal (cdadr m) "")
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
268 (equal (cdar m) (cdaddr m))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
269 (goto-char (caadr m))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
270 (forward-line 1)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
271 (= (point) (caaddr m)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
272 (setcdr m (cdddr m))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
273 (setq m (cdr m))))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
274 marks))))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
275
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
276
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
277 (defun gnus-article-fill-cited-article (&optional force)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
278 "Do word wrapping in the current article."
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
279 (interactive (list t))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
280 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
281 (set-buffer gnus-article-buffer)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
282 (let ((buffer-read-only nil)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
283 (inhibit-point-motion-hooks t)
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
284 (marks (gnus-dissect-cited-text))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
285 (adaptive-fill-mode nil))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
286 (save-restriction
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
287 (while (cdr marks)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
288 (widen)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
289 (narrow-to-region (caar marks) (caadr marks))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
290 (let ((adaptive-fill-regexp
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
291 (concat "^" (regexp-quote (cdar marks)) " *"))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
292 (fill-prefix (cdar marks)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
293 (fill-region (point-min) (point-max)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
294 (set-marker (caar marks) nil)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
295 (setq marks (cdr marks)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
296 (when marks
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
297 (set-marker (caar marks) nil))))))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
298
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
299 (defun gnus-article-hide-citation (&optional arg force)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
300 "Toggle hiding of all cited text except attribution lines.
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
301 See the documentation for `gnus-article-highlight-citation'.
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
302 If given a negative prefix, always show; if given a positive prefix,
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
303 always hide."
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
304 (interactive (append (gnus-hidden-arg) (list 'force)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
305 (setq gnus-cited-text-button-line-format-spec
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
306 (gnus-parse-format gnus-cited-text-button-line-format
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
307 gnus-cited-text-button-line-format-alist t))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
308 (unless (gnus-article-check-hidden-text 'cite arg)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
309 (save-excursion
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
310 (set-buffer gnus-article-buffer)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
311 (let ((buffer-read-only nil)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
312 (marks (gnus-dissect-cited-text))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
313 (inhibit-point-motion-hooks t)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
314 (props (nconc (list 'gnus-type 'cite)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
315 gnus-hidden-properties))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
316 beg end)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
317 (while marks
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
318 (setq beg nil
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
319 end nil)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
320 (while (and marks (string= (cdar marks) ""))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
321 (setq marks (cdr marks)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
322 (when marks
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
323 (setq beg (caar marks)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
324 (while (and marks (not (string= (cdar marks) "")))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
325 (setq marks (cdr marks)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
326 (when marks
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
327 (setq end (caar marks)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
328 ;; Skip past lines we want to leave visible.
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
329 (when (and beg end gnus-cited-lines-visible)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
330 (goto-char beg)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
331 (forward-line gnus-cited-lines-visible)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
332 (if (>= (point) end)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
333 (setq beg nil)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
334 (setq beg (point-marker))))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
335 (when (and beg end)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
336 (gnus-add-text-properties beg end props)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
337 (goto-char beg)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
338 (unless (save-excursion (search-backward "\n\n" nil t))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
339 (insert "\n"))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
340 (gnus-article-add-button
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
341 (point)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
342 (progn (eval gnus-cited-text-button-line-format-spec) (point))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
343 `gnus-article-toggle-cited-text (cons beg end))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
344 (set-marker beg (point))))))))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
345
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
346 (defun gnus-article-toggle-cited-text (region)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
347 "Toggle hiding the text in REGION."
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
348 (let (buffer-read-only)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
349 (funcall
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
350 (if (text-property-any
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
351 (car region) (1- (cdr region))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
352 (car gnus-hidden-properties) (cadr gnus-hidden-properties))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
353 'remove-text-properties 'gnus-add-text-properties)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
354 (car region) (cdr region) gnus-hidden-properties)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
355
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
356 (defun gnus-article-hide-citation-maybe (&optional arg force)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
357 "Toggle hiding of cited text that has an attribution line.
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
358 If given a negative prefix, always show; if given a positive prefix,
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
359 always hide.
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
360 This will do nothing unless at least `gnus-cite-hide-percentage'
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
361 percent and at least `gnus-cite-hide-absolute' lines of the body is
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
362 cited text with attributions. When called interactively, these two
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
363 variables are ignored.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
364 See also the documentation for `gnus-article-highlight-citation'."
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
365 (interactive (append (gnus-hidden-arg) (list 'force)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
366 (unless (gnus-article-check-hidden-text 'cite arg)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
367 (save-excursion
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
368 (set-buffer gnus-article-buffer)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
369 (gnus-cite-parse-maybe force)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
370 (goto-char (point-min))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
371 (search-forward "\n\n" nil t)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
372 (let ((start (point))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
373 (atts gnus-cite-attribution-alist)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
374 (buffer-read-only nil)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
375 (inhibit-point-motion-hooks t)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
376 (hiden 0)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
377 total)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
378 (goto-char (point-max))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
379 (re-search-backward gnus-signature-separator nil t)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
380 (setq total (count-lines start (point)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
381 (while atts
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
382 (setq hiden (+ hiden (length (cdr (assoc (cdar atts)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
383 gnus-cite-prefix-alist))))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
384 atts (cdr atts)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
385 (if (or force
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
386 (and (> (* 100 hiden) (* gnus-cite-hide-percentage total))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
387 (> hiden gnus-cite-hide-absolute)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
388 (progn
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
389 (setq atts gnus-cite-attribution-alist)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
390 (while atts
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
391 (setq total (cdr (assoc (cdar atts) gnus-cite-prefix-alist))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
392 atts (cdr atts))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
393 (while total
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
394 (setq hiden (car total)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
395 total (cdr total))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
396 (goto-line hiden)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
397 (or (assq hiden gnus-cite-attribution-alist)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
398 (gnus-add-text-properties
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
399 (point) (progn (forward-line 1) (point))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
400 (nconc (list 'gnus-type 'cite)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
401 gnus-hidden-properties)))))))))))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
402
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
403 (defun gnus-article-hide-citation-in-followups ()
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
404 "Hide cited text in non-root articles."
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
405 (interactive)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
406 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
407 (set-buffer gnus-article-buffer)
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
408 (let ((article (cdr gnus-article-current)))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
409 (unless (save-excursion
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
410 (set-buffer gnus-summary-buffer)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
411 (gnus-article-displayed-root-p article))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
412 (gnus-article-hide-citation)))))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
413
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
414 ;;; Internal functions:
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
415
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
416 (defun gnus-cite-parse-maybe (&optional force)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
417 ;; Parse if the buffer has changes since last time.
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
418 (if (equal gnus-cite-article gnus-article-current)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
419 ()
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
420 ;;Reset parser information.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
421 (setq gnus-cite-prefix-alist nil
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
422 gnus-cite-attribution-alist nil
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
423 gnus-cite-loose-prefix-alist nil
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
424 gnus-cite-loose-attribution-alist nil)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
425 ;; Parse if not too large.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
426 (if (and (not force)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
427 gnus-cite-parse-max-size
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
428 (> (buffer-size) gnus-cite-parse-max-size))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
429 ()
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
430 (setq gnus-cite-article (cons (car gnus-article-current)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
431 (cdr gnus-article-current)))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
432 (gnus-cite-parse))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
433
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
434 (defun gnus-cite-parse ()
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
435 ;; Parse and connect citation prefixes and attribution lines.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
436
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
437 ;; Parse current buffer searching for citation prefixes.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
438 (goto-char (point-min))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
439 (or (search-forward "\n\n" nil t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
440 (goto-char (point-max)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
441 (let ((line (1+ (count-lines (point-min) (point))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
442 (case-fold-search t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
443 (max (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
444 (goto-char (point-max))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
445 (re-search-backward gnus-signature-separator nil t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
446 (point)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
447 alist entry start begin end numbers prefix)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
448 ;; Get all potential prefixes in `alist'.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
449 (while (< (point) max)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
450 ;; Each line.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
451 (setq begin (point)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
452 end (progn (beginning-of-line 2) (point))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
453 start end)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
454 (goto-char begin)
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
455 ;; Ignore standard Supercite attribution prefix.
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
456 (if (looking-at gnus-supercite-regexp)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
457 (if (match-end 1)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
458 (setq end (1+ (match-end 1)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
459 (setq end (1+ begin))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
460 ;; Ignore very long prefixes.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
461 (if (> end (+ (point) gnus-cite-max-prefix))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
462 (setq end (+ (point) gnus-cite-max-prefix)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
463 (while (re-search-forward gnus-cite-prefix-regexp (1- end) t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
464 ;; Each prefix.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
465 (setq end (match-end 0)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
466 prefix (buffer-substring begin end))
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
467 (gnus-set-text-properties 0 (length prefix) nil prefix)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
468 (setq entry (assoc prefix alist))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
469 (if entry
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
470 (setcdr entry (cons line (cdr entry)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
471 (setq alist (cons (list prefix line) alist)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
472 (goto-char begin))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
473 (goto-char start)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
474 (setq line (1+ line)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
475 ;; We got all the potential prefixes. Now create
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
476 ;; `gnus-cite-prefix-alist' containing the oldest prefix for each
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
477 ;; line that appears at least gnus-cite-minimum-match-count
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
478 ;; times. First sort them by length. Longer is older.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
479 (setq alist (sort alist (lambda (a b)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
480 (> (length (car a)) (length (car b))))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
481 (while alist
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
482 (setq entry (car alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
483 prefix (car entry)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
484 numbers (cdr entry)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
485 alist (cdr alist))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
486 (cond ((null numbers)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
487 ;; No lines with this prefix that wasn't also part of
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
488 ;; a longer prefix.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
489 )
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
490 ((< (length numbers) gnus-cite-minimum-match-count)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
491 ;; Too few lines with this prefix. We keep it a bit
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
492 ;; longer in case it is an exact match for an attribution
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
493 ;; line, but we don't remove the line from other
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
494 ;; prefixes.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
495 (setq gnus-cite-prefix-alist
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
496 (cons entry gnus-cite-prefix-alist)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
497 (t
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
498 (setq gnus-cite-prefix-alist (cons entry
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
499 gnus-cite-prefix-alist))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
500 ;; Remove articles from other prefixes.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
501 (let ((loop alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
502 current)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
503 (while loop
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
504 (setq current (car loop)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
505 loop (cdr loop))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
506 (setcdr current
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
507 (gnus-set-difference (cdr current) numbers))))))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
508 ;; No citations have been connected to attribution lines yet.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
509 (setq gnus-cite-loose-prefix-alist (append gnus-cite-prefix-alist nil))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
510
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
511 ;; Parse current buffer searching for attribution lines.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
512 (goto-char (point-min))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
513 (search-forward "\n\n" nil t)
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
514 (while (re-search-forward gnus-cite-attribution-suffix (point-max) t)
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
515 (let* ((start (match-beginning 0))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
516 (end (match-end 0))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
517 (wrote (count-lines (point-min) end))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
518 (prefix (gnus-cite-find-prefix wrote))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
519 ;; Check previous line for an attribution leader.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
520 (tag (progn
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
521 (beginning-of-line 1)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
522 (and (looking-at gnus-supercite-secondary-regexp)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
523 (buffer-substring (match-beginning 1)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
524 (match-end 1)))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
525 (in (progn
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
526 (goto-char start)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
527 (and (re-search-backward gnus-cite-attribution-prefix
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
528 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
529 (beginning-of-line 0)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
530 (point))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
531 t)
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
532 (not (re-search-forward gnus-cite-attribution-suffix
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
533 start t))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
534 (count-lines (point-min) (1+ (point)))))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
535 (if (eq wrote in)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
536 (setq in nil))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
537 (goto-char end)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
538 (setq gnus-cite-loose-attribution-alist
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
539 (cons (list wrote in prefix tag)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
540 gnus-cite-loose-attribution-alist))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
541 ;; Find exact supercite citations.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
542 (gnus-cite-match-attributions 'small nil
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
543 (lambda (prefix tag)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
544 (if tag
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
545 (concat "\\`"
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
546 (regexp-quote prefix) "[ \t]*"
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
547 (regexp-quote tag) ">"))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
548 ;; Find loose supercite citations after attributions.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
549 (gnus-cite-match-attributions 'small t
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
550 (lambda (prefix tag)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
551 (if tag (concat "\\<"
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
552 (regexp-quote tag)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
553 "\\>"))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
554 ;; Find loose supercite citations anywhere.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
555 (gnus-cite-match-attributions 'small nil
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
556 (lambda (prefix tag)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
557 (if tag (concat "\\<"
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
558 (regexp-quote tag)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
559 "\\>"))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
560 ;; Find nested citations after attributions.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
561 (gnus-cite-match-attributions 'small-if-unique t
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
562 (lambda (prefix tag)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
563 (concat "\\`" (regexp-quote prefix) ".+")))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
564 ;; Find nested citations anywhere.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
565 (gnus-cite-match-attributions 'small nil
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
566 (lambda (prefix tag)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
567 (concat "\\`" (regexp-quote prefix) ".+")))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
568 ;; Remove loose prefixes with too few lines.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
569 (let ((alist gnus-cite-loose-prefix-alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
570 entry)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
571 (while alist
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
572 (setq entry (car alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
573 alist (cdr alist))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
574 (if (< (length (cdr entry)) gnus-cite-minimum-match-count)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
575 (setq gnus-cite-prefix-alist
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
576 (delq entry gnus-cite-prefix-alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
577 gnus-cite-loose-prefix-alist
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
578 (delq entry gnus-cite-loose-prefix-alist)))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
579 ;; Find flat attributions.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
580 (gnus-cite-match-attributions 'first t nil)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
581 ;; Find any attributions (are we getting desperate yet?).
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
582 (gnus-cite-match-attributions 'first nil nil))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
583
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
584 (defun gnus-cite-match-attributions (sort after fun)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
585 ;; Match all loose attributions and citations (SORT AFTER FUN) .
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
586 ;;
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
587 ;; If SORT is `small', the citation with the shortest prefix will be
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
588 ;; used, if it is `first' the first prefix will be used, if it is
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
589 ;; `small-if-unique' the shortest prefix will be used if the
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
590 ;; attribution line does not share its own prefix with other
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
591 ;; loose attribution lines, otherwise the first prefix will be used.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
592 ;;
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
593 ;; If AFTER is non-nil, only citations after the attribution line
14040
187735b53d52 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13401
diff changeset
594 ;; will be considered.
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
595 ;;
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
596 ;; If FUN is non-nil, it will be called with the arguments (WROTE
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
597 ;; PREFIX TAG) and expected to return a regular expression. Only
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
598 ;; citations whose prefix matches the regular expression will be
14040
187735b53d52 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13401
diff changeset
599 ;; considered.
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
600 ;;
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
601 ;; WROTE is the attribution line number.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
602 ;; PREFIX is the attribution line prefix.
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
603 ;; TAG is the Supercite tag on the attribution line.
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
604 (let ((atts gnus-cite-loose-attribution-alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
605 (case-fold-search t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
606 att wrote in prefix tag regexp limit smallest best size)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
607 (while atts
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
608 (setq att (car atts)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
609 atts (cdr atts)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
610 wrote (nth 0 att)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
611 in (nth 1 att)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
612 prefix (nth 2 att)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
613 tag (nth 3 att)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
614 regexp (if fun (funcall fun prefix tag) "")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
615 size (cond ((eq sort 'small) t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
616 ((eq sort 'first) nil)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
617 (t (< (length (gnus-cite-find-loose prefix)) 2)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
618 limit (if after wrote -1)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
619 smallest 1000000
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
620 best nil)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
621 (let ((cites gnus-cite-loose-prefix-alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
622 cite candidate numbers first compare)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
623 (while cites
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
624 (setq cite (car cites)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
625 cites (cdr cites)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
626 candidate (car cite)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
627 numbers (cdr cite)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
628 first (apply 'min numbers)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
629 compare (if size (length candidate) first))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
630 (and (> first limit)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
631 regexp
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
632 (string-match regexp candidate)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
633 (< compare smallest)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
634 (setq best cite
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
635 smallest compare))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
636 (if (null best)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
637 ()
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
638 (setq gnus-cite-loose-attribution-alist
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
639 (delq att gnus-cite-loose-attribution-alist))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
640 (setq gnus-cite-attribution-alist
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
641 (cons (cons wrote (car best)) gnus-cite-attribution-alist))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
642 (if in
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
643 (setq gnus-cite-attribution-alist
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
644 (cons (cons in (car best)) gnus-cite-attribution-alist)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
645 (if (memq best gnus-cite-loose-prefix-alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
646 (let ((loop gnus-cite-prefix-alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
647 (numbers (cdr best))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
648 current)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
649 (setq gnus-cite-loose-prefix-alist
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
650 (delq best gnus-cite-loose-prefix-alist))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
651 (while loop
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
652 (setq current (car loop)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
653 loop (cdr loop))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
654 (if (eq current best)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
655 ()
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
656 (setcdr current (gnus-set-difference (cdr current) numbers))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
657 (if (null (cdr current))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
658 (setq gnus-cite-loose-prefix-alist
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
659 (delq current gnus-cite-loose-prefix-alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
660 atts (delq current atts)))))))))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
661
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
662 (defun gnus-cite-find-loose (prefix)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
663 ;; Return a list of loose attribution lines prefixed by PREFIX.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
664 (let* ((atts gnus-cite-loose-attribution-alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
665 att line lines)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
666 (while atts
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
667 (setq att (car atts)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
668 line (car att)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
669 atts (cdr atts))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
670 (if (string-equal (gnus-cite-find-prefix line) prefix)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
671 (setq lines (cons line lines))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
672 lines))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
673
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
674 (defun gnus-cite-add-face (number prefix face)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
675 ;; At line NUMBER, ignore PREFIX and add FACE to the rest of the line.
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
676 (when face
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
677 (let ((inhibit-point-motion-hooks t)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
678 from to)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
679 (goto-line number)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
680 (unless (eobp) ;; Sometimes things become confused.
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
681 (forward-char (length prefix))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
682 (skip-chars-forward " \t")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
683 (setq from (point))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
684 (end-of-line 1)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
685 (skip-chars-backward " \t")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
686 (setq to (point))
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
687 (when (< from to)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
688 (gnus-overlay-put (gnus-make-overlay from to) 'face face))))))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
689
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
690 (defun gnus-cite-toggle (prefix)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
691 (save-excursion
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
692 (set-buffer gnus-article-buffer)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
693 (let ((buffer-read-only nil)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
694 (numbers (cdr (assoc prefix gnus-cite-prefix-alist)))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
695 (inhibit-point-motion-hooks t)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
696 number)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
697 (while numbers
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
698 (setq number (car numbers)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
699 numbers (cdr numbers))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
700 (goto-line number)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
701 (cond ((get-text-property (point) 'invisible)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
702 (remove-text-properties (point) (progn (forward-line 1) (point))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
703 gnus-hidden-properties))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
704 ((assq number gnus-cite-attribution-alist))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
705 (t
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
706 (gnus-add-text-properties
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
707 (point) (progn (forward-line 1) (point))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
708 (nconc (list 'gnus-type 'cite)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
709 gnus-hidden-properties))))))))
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
710
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
711 (defun gnus-cite-find-prefix (line)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
712 ;; Return citation prefix for LINE.
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
713 (let ((alist gnus-cite-prefix-alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
714 (prefix "")
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
715 entry)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
716 (while alist
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
717 (setq entry (car alist)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
718 alist (cdr alist))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
719 (if (memq line (cdr entry))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
720 (setq prefix (car entry))))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
721 prefix))
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
722
15511
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
723 (gnus-add-shutdown 'gnus-cache-close 'gnus)
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
724
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
725 (defun gnus-cache-close ()
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
726 (setq gnus-cite-prefix-alist nil))
530d0d516a42 New version.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 14169
diff changeset
727
13401
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
728 (gnus-ems-redefine)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
729
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
730 (provide 'gnus-cite)
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
731
178d730efae2 entered into RCS
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
diff changeset
732 ;;; gnus-cite.el ends here