Mercurial > emacs
annotate lisp/gnus/gnus-cite.el @ 52677:a4cf4569e557
(scheme-mode-variables): When setting
`font-lock-defaults', also specify that "#" should
be interpreted with `word' syntax.
(scheme-font-lock-keywords-2): Also interpret "#:foo" as keyword.
author | Thien-Thi Nguyen <ttn@gnuvola.org> |
---|---|
date | Tue, 30 Sep 2003 11:46:13 +0000 |
parents | 695cf19ef79e |
children | 55fd4f77387a 0fde48feb604 375f2633d815 |
rev | line source |
---|---|
33374 | 1 ;;; gnus-cite.el --- parse citations in articles for Gnus -*- coding: iso-latin-1 -*- |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2 |
42475
1e4516b1d514
2002-01-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34727
diff
changeset
|
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
17493 | 5 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
6 ;; Author: Per Abhiddenware |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
7 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
9 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
10 ;; GNU Emacs is free software; you can redistribute it and/or modify |
17493 | 11 ;; it under the terms of the GNU General Public License as published by |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;;; Code: | |
28 | |
19521
6f6cf9184e93
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
29 (eval-when-compile (require 'cl)) |
6f6cf9184e93
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
30 |
17493 | 31 (require 'gnus) |
32 (require 'gnus-art) | |
33 (require 'gnus-range) | |
34 | |
35 ;;; Customization: | |
36 | |
37 (defgroup gnus-cite nil | |
38 "Citation." | |
39 :prefix "gnus-cite-" | |
40 :link '(custom-manual "(gnus)Article Highlighting") | |
41 :group 'gnus-article) | |
42 | |
43 (defcustom gnus-cite-reply-regexp | |
44 "^\\(Subject: Re\\|In-Reply-To\\|References\\):" | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
45 "*If headers match this regexp it is reasonable to believe that |
17493 | 46 article has citations." |
47 :group 'gnus-cite | |
48 :type 'string) | |
49 | |
50 (defcustom gnus-cite-always-check nil | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
51 "Check article always for citations. Set it t to check all articles." |
17493 | 52 :group 'gnus-cite |
53 :type '(choice (const :tag "no" nil) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
54 (const :tag "yes" t))) |
17493 | 55 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
56 (defcustom gnus-cited-opened-text-button-line-format "%(%{[-]%}%)\n" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
57 "Format of opened cited text buttons." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
58 :group 'gnus-cite |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
59 :type 'string) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
60 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
61 (defcustom gnus-cited-closed-text-button-line-format "%(%{[+]%}%)\n" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
62 "Format of closed cited text buttons." |
17493 | 63 :group 'gnus-cite |
64 :type 'string) | |
65 | |
66 (defcustom gnus-cited-lines-visible nil | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
67 "The number of lines of hidden cited text to remain visible. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
68 Or a pair (cons) of numbers which are the number of lines at the top |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
69 and bottom of the text, respectively, to remain visible." |
17493 | 70 :group 'gnus-cite |
71 :type '(choice (const :tag "none" nil) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
72 integer |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
73 (cons :tag "Top and Bottom" integer integer))) |
17493 | 74 |
75 (defcustom gnus-cite-parse-max-size 25000 | |
76 "Maximum article size (in bytes) where parsing citations is allowed. | |
77 Set it to nil to parse all articles." | |
78 :group 'gnus-cite | |
79 :type '(choice (const :tag "all" nil) | |
80 integer)) | |
81 | |
82 (defcustom gnus-cite-prefix-regexp | |
33374 | 83 ;; The Latin-1 angle quote looks pretty dubious. -- fx |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
84 "^[]>»|:}+ ]*[]>»|:}+]\\(.*>»\\)?\\|^.*>" |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
85 "*Regexp matching the longest possible citation prefix on a line." |
17493 | 86 :group 'gnus-cite |
87 :type 'regexp) | |
88 | |
89 (defcustom gnus-cite-max-prefix 20 | |
90 "Maximum possible length for a citation prefix." | |
91 :group 'gnus-cite | |
92 :type 'integer) | |
93 | |
94 (defcustom gnus-supercite-regexp | |
95 (concat "^\\(" gnus-cite-prefix-regexp "\\)? *" | |
96 ">>>>> +\"\\([^\"\n]+\\)\" +==") | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
97 "*Regexp matching normal Supercite attribution lines. |
17493 | 98 The first grouping must match prefixes added by other packages." |
99 :group 'gnus-cite | |
100 :type 'regexp) | |
101 | |
102 (defcustom gnus-supercite-secondary-regexp "^.*\"\\([^\"\n]+\\)\" +==" | |
103 "Regexp matching mangled Supercite attribution lines. | |
104 The first regexp group should match the Supercite attribution." | |
105 :group 'gnus-cite | |
106 :type 'regexp) | |
107 | |
108 (defcustom gnus-cite-minimum-match-count 2 | |
109 "Minimum number of identical prefixes before we believe it's a citation." | |
110 :group 'gnus-cite | |
111 :type 'integer) | |
112 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
113 (defcustom gnus-cite-attribution-prefix |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
114 "In article\\|in <\\|On \\(Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\|Sun\\),\\|-----Original Message-----" |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
115 "*Regexp matching the beginning of an attribution line." |
17493 | 116 :group 'gnus-cite |
117 :type 'regexp) | |
118 | |
119 (defcustom gnus-cite-attribution-suffix | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
120 "\\(\\(wrote\\|writes\\|said\\|says\\|>\\)\\(:\\|\\.\\.\\.\\)\\|-----Original Message-----\\)[ \t]*$" |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
121 "*Regexp matching the end of an attribution line. |
17493 | 122 The text matching the first grouping will be used as a button." |
123 :group 'gnus-cite | |
124 :type 'regexp) | |
125 | |
126 (defface gnus-cite-attribution-face '((t | |
42475
1e4516b1d514
2002-01-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34727
diff
changeset
|
127 (:slant italic))) |
17493 | 128 "Face used for attribution lines.") |
129 | |
130 (defcustom gnus-cite-attribution-face 'gnus-cite-attribution-face | |
131 "Face used for attribution lines. | |
132 It is merged with the face for the cited text belonging to the attribution." | |
133 :group 'gnus-cite | |
134 :type 'face) | |
135 | |
136 (defface gnus-cite-face-1 '((((class color) | |
137 (background dark)) | |
138 (:foreground "light blue")) | |
139 (((class color) | |
140 (background light)) | |
141 (:foreground "MidnightBlue")) | |
142 (t | |
42475
1e4516b1d514
2002-01-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34727
diff
changeset
|
143 (:slant italic))) |
17493 | 144 "Citation face.") |
145 | |
146 (defface gnus-cite-face-2 '((((class color) | |
147 (background dark)) | |
148 (:foreground "light cyan")) | |
149 (((class color) | |
150 (background light)) | |
151 (:foreground "firebrick")) | |
152 (t | |
42475
1e4516b1d514
2002-01-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34727
diff
changeset
|
153 (:slant italic))) |
17493 | 154 "Citation face.") |
155 | |
156 (defface gnus-cite-face-3 '((((class color) | |
157 (background dark)) | |
158 (:foreground "light yellow")) | |
159 (((class color) | |
160 (background light)) | |
161 (:foreground "dark green")) | |
162 (t | |
42475
1e4516b1d514
2002-01-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34727
diff
changeset
|
163 (:slant italic))) |
17493 | 164 "Citation face.") |
165 | |
166 (defface gnus-cite-face-4 '((((class color) | |
167 (background dark)) | |
168 (:foreground "light pink")) | |
169 (((class color) | |
170 (background light)) | |
171 (:foreground "OrangeRed")) | |
172 (t | |
42475
1e4516b1d514
2002-01-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34727
diff
changeset
|
173 (:slant italic))) |
17493 | 174 "Citation face.") |
175 | |
176 (defface gnus-cite-face-5 '((((class color) | |
177 (background dark)) | |
178 (:foreground "pale green")) | |
179 (((class color) | |
180 (background light)) | |
181 (:foreground "dark khaki")) | |
182 (t | |
42475
1e4516b1d514
2002-01-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34727
diff
changeset
|
183 (:slant italic))) |
17493 | 184 "Citation face.") |
185 | |
186 (defface gnus-cite-face-6 '((((class color) | |
187 (background dark)) | |
188 (:foreground "beige")) | |
189 (((class color) | |
190 (background light)) | |
191 (:foreground "dark violet")) | |
192 (t | |
42475
1e4516b1d514
2002-01-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34727
diff
changeset
|
193 (:slant italic))) |
17493 | 194 "Citation face.") |
195 | |
196 (defface gnus-cite-face-7 '((((class color) | |
197 (background dark)) | |
198 (:foreground "orange")) | |
199 (((class color) | |
200 (background light)) | |
201 (:foreground "SteelBlue4")) | |
202 (t | |
42475
1e4516b1d514
2002-01-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34727
diff
changeset
|
203 (:slant italic))) |
17493 | 204 "Citation face.") |
205 | |
206 (defface gnus-cite-face-8 '((((class color) | |
207 (background dark)) | |
208 (:foreground "magenta")) | |
209 (((class color) | |
210 (background light)) | |
211 (:foreground "magenta")) | |
212 (t | |
42475
1e4516b1d514
2002-01-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34727
diff
changeset
|
213 (:slant italic))) |
17493 | 214 "Citation face.") |
215 | |
216 (defface gnus-cite-face-9 '((((class color) | |
217 (background dark)) | |
218 (:foreground "violet")) | |
219 (((class color) | |
220 (background light)) | |
221 (:foreground "violet")) | |
222 (t | |
42475
1e4516b1d514
2002-01-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34727
diff
changeset
|
223 (:slant italic))) |
17493 | 224 "Citation face.") |
225 | |
226 (defface gnus-cite-face-10 '((((class color) | |
227 (background dark)) | |
228 (:foreground "medium purple")) | |
229 (((class color) | |
230 (background light)) | |
231 (:foreground "medium purple")) | |
232 (t | |
42475
1e4516b1d514
2002-01-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34727
diff
changeset
|
233 (:slant italic))) |
17493 | 234 "Citation face.") |
235 | |
236 (defface gnus-cite-face-11 '((((class color) | |
237 (background dark)) | |
238 (:foreground "turquoise")) | |
239 (((class color) | |
240 (background light)) | |
241 (:foreground "turquoise")) | |
242 (t | |
42475
1e4516b1d514
2002-01-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34727
diff
changeset
|
243 (:slant italic))) |
17493 | 244 "Citation face.") |
245 | |
246 (defcustom gnus-cite-face-list | |
247 '(gnus-cite-face-1 gnus-cite-face-2 gnus-cite-face-3 gnus-cite-face-4 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
248 gnus-cite-face-5 gnus-cite-face-6 gnus-cite-face-7 gnus-cite-face-8 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
249 gnus-cite-face-9 gnus-cite-face-10 gnus-cite-face-11) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
250 "*List of faces used for highlighting citations. |
17493 | 251 |
252 When there are citations from multiple articles in the same message, | |
253 Gnus will try to give each citation from each article its own face. | |
254 This should make it easier to see who wrote what." | |
255 :group 'gnus-cite | |
256 :type '(repeat face)) | |
257 | |
258 (defcustom gnus-cite-hide-percentage 50 | |
259 "Only hide excess citation if above this percentage of the body." | |
260 :group 'gnus-cite | |
261 :type 'number) | |
262 | |
263 (defcustom gnus-cite-hide-absolute 10 | |
264 "Only hide excess citation if above this number of lines in the body." | |
265 :group 'gnus-cite | |
266 :type 'integer) | |
267 | |
45202
79139aa0f18c
(gnus-cite-blank-line-after-header): New variable.
Miles Bader <miles@gnu.org>
parents:
42475
diff
changeset
|
268 (defcustom gnus-cite-blank-line-after-header t |
79139aa0f18c
(gnus-cite-blank-line-after-header): New variable.
Miles Bader <miles@gnu.org>
parents:
42475
diff
changeset
|
269 "If non-nil, put a blank line between the citation header and the button." |
79139aa0f18c
(gnus-cite-blank-line-after-header): New variable.
Miles Bader <miles@gnu.org>
parents:
42475
diff
changeset
|
270 :group 'gnus-cite |
79139aa0f18c
(gnus-cite-blank-line-after-header): New variable.
Miles Bader <miles@gnu.org>
parents:
42475
diff
changeset
|
271 :type 'boolean) |
79139aa0f18c
(gnus-cite-blank-line-after-header): New variable.
Miles Bader <miles@gnu.org>
parents:
42475
diff
changeset
|
272 |
17493 | 273 ;;; Internal Variables: |
274 | |
275 (defvar gnus-cite-article nil) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
276 (defvar gnus-cite-overlay-list nil) |
17493 | 277 |
278 (defvar gnus-cite-prefix-alist nil) | |
279 ;; Alist of citation prefixes. | |
280 ;; The cdr is a list of lines with that prefix. | |
281 | |
282 (defvar gnus-cite-attribution-alist nil) | |
283 ;; Alist of attribution lines. | |
284 ;; The car is a line number. | |
285 ;; The cdr is the prefix for the citation started by that line. | |
286 | |
287 (defvar gnus-cite-loose-prefix-alist nil) | |
288 ;; Alist of citation prefixes that have no matching attribution. | |
289 ;; The cdr is a list of lines with that prefix. | |
290 | |
291 (defvar gnus-cite-loose-attribution-alist nil) | |
292 ;; Alist of attribution lines that have no matching citation. | |
293 ;; Each member has the form (WROTE IN PREFIX TAG), where | |
294 ;; WROTE: is the attribution line number | |
295 ;; IN: is the line number of the previous line if part of the same attribution, | |
296 ;; PREFIX: Is the citation prefix of the attribution line(s), and | |
297 ;; TAG: Is a Supercite tag, if any. | |
298 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
299 (defvar gnus-cited-opened-text-button-line-format-alist |
17493 | 300 `((?b (marker-position beg) ?d) |
301 (?e (marker-position end) ?d) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
302 (?n (count-lines beg end) ?d) |
17493 | 303 (?l (- end beg) ?d))) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
304 (defvar gnus-cited-opened-text-button-line-format-spec nil) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
305 (defvar gnus-cited-closed-text-button-line-format-alist |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
306 gnus-cited-opened-text-button-line-format-alist) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
307 (defvar gnus-cited-closed-text-button-line-format-spec nil) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
308 |
17493 | 309 |
310 ;;; Commands: | |
311 | |
312 (defun gnus-article-highlight-citation (&optional force) | |
313 "Highlight cited text. | |
314 Each citation in the article will be highlighted with a different face. | |
315 The faces are taken from `gnus-cite-face-list'. | |
316 Attribution lines are highlighted with the same face as the | |
317 corresponding citation merged with `gnus-cite-attribution-face'. | |
318 | |
319 Text is considered cited if at least `gnus-cite-minimum-match-count' | |
320 lines matches `gnus-cite-prefix-regexp' with the same prefix. | |
321 | |
322 Lines matching `gnus-cite-attribution-suffix' and perhaps | |
323 `gnus-cite-attribution-prefix' are considered attribution lines." | |
324 (interactive (list 'force)) | |
325 (save-excursion | |
326 (set-buffer gnus-article-buffer) | |
327 (gnus-cite-parse-maybe force) | |
328 (let ((buffer-read-only nil) | |
329 (alist gnus-cite-prefix-alist) | |
330 (faces gnus-cite-face-list) | |
331 (inhibit-point-motion-hooks t) | |
332 face entry prefix skip numbers number face-alist) | |
333 ;; Loop through citation prefixes. | |
334 (while alist | |
335 (setq entry (car alist) | |
336 alist (cdr alist) | |
337 prefix (car entry) | |
338 numbers (cdr entry) | |
339 face (car faces) | |
340 faces (or (cdr faces) gnus-cite-face-list) | |
341 face-alist (cons (cons prefix face) face-alist)) | |
342 (while numbers | |
343 (setq number (car numbers) | |
344 numbers (cdr numbers)) | |
345 (and (not (assq number gnus-cite-attribution-alist)) | |
346 (not (assq number gnus-cite-loose-attribution-alist)) | |
347 (gnus-cite-add-face number prefix face)))) | |
348 ;; Loop through attribution lines. | |
349 (setq alist gnus-cite-attribution-alist) | |
350 (while alist | |
351 (setq entry (car alist) | |
352 alist (cdr alist) | |
353 number (car entry) | |
354 prefix (cdr entry) | |
355 skip (gnus-cite-find-prefix number) | |
356 face (cdr (assoc prefix face-alist))) | |
357 ;; Add attribution button. | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
358 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
359 (forward-line (1- number)) |
17493 | 360 (when (re-search-forward gnus-cite-attribution-suffix |
361 (save-excursion (end-of-line 1) (point)) | |
362 t) | |
363 (gnus-article-add-button (match-beginning 1) (match-end 1) | |
364 'gnus-cite-toggle prefix)) | |
365 ;; Highlight attribution line. | |
366 (gnus-cite-add-face number skip face) | |
367 (gnus-cite-add-face number skip gnus-cite-attribution-face)) | |
368 ;; Loop through attribution lines. | |
369 (setq alist gnus-cite-loose-attribution-alist) | |
370 (while alist | |
371 (setq entry (car alist) | |
372 alist (cdr alist) | |
373 number (car entry) | |
374 skip (gnus-cite-find-prefix number)) | |
375 (gnus-cite-add-face number skip gnus-cite-attribution-face))))) | |
376 | |
377 (defun gnus-dissect-cited-text () | |
378 "Dissect the article buffer looking for cited text." | |
379 (save-excursion | |
380 (set-buffer gnus-article-buffer) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
381 (gnus-cite-parse-maybe nil t) |
17493 | 382 (let ((alist gnus-cite-prefix-alist) |
383 prefix numbers number marks m) | |
384 ;; Loop through citation prefixes. | |
385 (while alist | |
386 (setq numbers (pop alist) | |
387 prefix (pop numbers)) | |
388 (while numbers | |
389 (setq number (pop numbers)) | |
390 (goto-char (point-min)) | |
391 (forward-line number) | |
392 (push (cons (point-marker) "") marks) | |
393 (while (and numbers | |
394 (= (1- number) (car numbers))) | |
395 (setq number (pop numbers))) | |
396 (goto-char (point-min)) | |
397 (forward-line (1- number)) | |
398 (push (cons (point-marker) prefix) marks))) | |
399 ;; Skip to the beginning of the body. | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
400 (article-goto-body) |
17493 | 401 (push (cons (point-marker) "") marks) |
402 ;; Find the end of the body. | |
403 (goto-char (point-max)) | |
404 (gnus-article-search-signature) | |
405 (push (cons (point-marker) "") marks) | |
406 ;; Sort the marks. | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
407 (setq marks (sort marks 'car-less-than-car)) |
17493 | 408 (let ((omarks marks)) |
409 (setq marks nil) | |
410 (while (cdr omarks) | |
411 (if (= (caar omarks) (caadr omarks)) | |
412 (progn | |
413 (unless (equal (cdar omarks) "") | |
414 (push (car omarks) marks)) | |
415 (unless (equal (cdadr omarks) "") | |
416 (push (cadr omarks) marks)) | |
417 (unless (and (equal (cdar omarks) "") | |
418 (equal (cdadr omarks) "") | |
419 (not (cddr omarks))) | |
420 (setq omarks (cdr omarks)))) | |
421 (push (car omarks) marks)) | |
422 (setq omarks (cdr omarks))) | |
423 (when (car omarks) | |
424 (push (car omarks) marks)) | |
425 (setq marks (setq m (nreverse marks))) | |
426 (while (cddr m) | |
427 (if (and (equal (cdadr m) "") | |
428 (equal (cdar m) (cdaddr m)) | |
429 (goto-char (caadr m)) | |
430 (forward-line 1) | |
431 (= (point) (caaddr m))) | |
432 (setcdr m (cdddr m)) | |
433 (setq m (cdr m)))) | |
434 marks)))) | |
435 | |
436 (defun gnus-article-fill-cited-article (&optional force width) | |
437 "Do word wrapping in the current article. | |
438 If WIDTH (the numerical prefix), use that text width when filling." | |
439 (interactive (list t current-prefix-arg)) | |
440 (save-excursion | |
441 (set-buffer gnus-article-buffer) | |
442 (let ((buffer-read-only nil) | |
443 (inhibit-point-motion-hooks t) | |
444 (marks (gnus-dissect-cited-text)) | |
445 (adaptive-fill-mode nil) | |
446 (filladapt-mode nil) | |
447 (fill-column (if width (prefix-numeric-value width) fill-column))) | |
448 (save-restriction | |
449 (while (cdr marks) | |
450 (narrow-to-region (caar marks) (caadr marks)) | |
451 (let ((adaptive-fill-regexp | |
452 (concat "^" (regexp-quote (cdar marks)) " *")) | |
453 (fill-prefix (cdar marks))) | |
454 (fill-region (point-min) (point-max))) | |
455 (set-marker (caar marks) nil) | |
456 (setq marks (cdr marks))) | |
457 (when marks | |
458 (set-marker (caar marks) nil)) | |
459 ;; All this information is now incorrect. | |
460 (setq gnus-cite-prefix-alist nil | |
461 gnus-cite-attribution-alist nil | |
462 gnus-cite-loose-prefix-alist nil | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
463 gnus-cite-loose-attribution-alist nil |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
464 gnus-cite-article nil))))) |
17493 | 465 |
466 (defun gnus-article-hide-citation (&optional arg force) | |
467 "Toggle hiding of all cited text except attribution lines. | |
468 See the documentation for `gnus-article-highlight-citation'. | |
469 If given a negative prefix, always show; if given a positive prefix, | |
470 always hide." | |
471 (interactive (append (gnus-article-hidden-arg) (list 'force))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
472 (gnus-set-format 'cited-opened-text-button t) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
473 (gnus-set-format 'cited-closed-text-button t) |
17493 | 474 (save-excursion |
475 (set-buffer gnus-article-buffer) | |
476 (let ((buffer-read-only nil) | |
34727
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
477 marks |
17493 | 478 (inhibit-point-motion-hooks t) |
479 (props (nconc (list 'article-type 'cite) | |
480 gnus-hidden-properties)) | |
34727
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
481 (point (point-min)) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
482 found beg end start) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45202
diff
changeset
|
483 (while (setq point |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45202
diff
changeset
|
484 (text-property-any point (point-max) |
34727
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
485 'gnus-callback |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
486 'gnus-article-toggle-cited-text)) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
487 (setq found t) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
488 (goto-char point) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
489 (gnus-article-toggle-cited-text |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
490 (get-text-property point 'gnus-data) arg) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
491 (forward-line 1) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
492 (setq point (point))) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
493 (unless found |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
494 (setq marks (gnus-dissect-cited-text)) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
495 (while marks |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
496 (setq beg nil |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
497 end nil) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
498 (while (and marks (string= (cdar marks) "")) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
499 (setq marks (cdr marks))) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
500 (when marks |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
501 (setq beg (caar marks))) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
502 (while (and marks (not (string= (cdar marks) ""))) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
503 (setq marks (cdr marks))) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
504 (when marks |
17493 | 505 (setq end (caar marks))) |
34727
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
506 ;; Skip past lines we want to leave visible. |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
507 (when (and beg end gnus-cited-lines-visible) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
508 (goto-char beg) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
509 (forward-line (if (consp gnus-cited-lines-visible) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
510 (car gnus-cited-lines-visible) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
511 gnus-cited-lines-visible)) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
512 (if (>= (point) end) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
513 (setq beg nil) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
514 (setq beg (point-marker)) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
515 (when (consp gnus-cited-lines-visible) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
516 (goto-char end) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
517 (forward-line (- (cdr gnus-cited-lines-visible))) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
518 (if (<= (point) beg) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
519 (setq beg nil) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
520 (setq end (point-marker)))))) |
34727
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
521 (when (and beg end) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
522 ;; We use markers for the end-points to facilitate later |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
523 ;; wrapping and mangling of text. |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
524 (setq beg (set-marker (make-marker) beg) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
525 end (set-marker (make-marker) end)) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
526 (gnus-add-text-properties-when 'article-type nil beg end props) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
527 (goto-char beg) |
45202
79139aa0f18c
(gnus-cite-blank-line-after-header): New variable.
Miles Bader <miles@gnu.org>
parents:
42475
diff
changeset
|
528 (when (and gnus-cite-blank-line-after-header |
79139aa0f18c
(gnus-cite-blank-line-after-header): New variable.
Miles Bader <miles@gnu.org>
parents:
42475
diff
changeset
|
529 (not (save-excursion (search-backward "\n\n" nil t)))) |
34727
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
530 (insert "\n")) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
531 (put-text-property |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
532 (setq start (point-marker)) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
533 (progn |
17493 | 534 (gnus-article-add-button |
535 (point) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
536 (progn (eval gnus-cited-closed-text-button-line-format-spec) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
537 (point)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
538 `gnus-article-toggle-cited-text |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
539 (list (cons beg end) start)) |
17493 | 540 (point)) |
34727
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
541 'article-type 'annotation) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
542 (set-marker beg (point)))))))) |
17493 | 543 |
34727
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
544 (defun gnus-article-toggle-cited-text (args &optional arg) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
545 "Toggle hiding the text in REGION. |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
546 ARG can be nil or a number. Positive means hide, negative |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
547 means show, nil means toggle." |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
548 (let* ((region (car args)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
549 (beg (car region)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
550 (end (cdr region)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
551 (start (cadr args)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
552 (hidden |
34727
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
553 (text-property-any beg (1- end) 'article-type 'cite)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
554 (inhibit-point-motion-hooks t) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
555 buffer-read-only) |
34727
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
556 (when (or (null arg) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
557 (zerop arg) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
558 (and (> arg 0) (not hidden)) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
559 (and (< arg 0) hidden)) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
560 (if hidden |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
561 (gnus-remove-text-properties-when |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45202
diff
changeset
|
562 'article-type 'cite beg end |
34727
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
563 (cons 'article-type (cons 'cite |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
564 gnus-hidden-properties))) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
565 (gnus-add-text-properties-when |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45202
diff
changeset
|
566 'article-type nil beg end |
34727
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
567 (cons 'article-type (cons 'cite |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
568 gnus-hidden-properties)))) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
569 (save-excursion |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
570 (goto-char start) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
571 (gnus-delete-line) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
572 (put-text-property |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
573 (point) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
574 (progn |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
575 (gnus-article-add-button |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
576 (point) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
577 (progn (eval |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
578 (if hidden |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
579 gnus-cited-opened-text-button-line-format-spec |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
580 gnus-cited-closed-text-button-line-format-spec)) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
581 (point)) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
582 `gnus-article-toggle-cited-text |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
583 args) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
584 (point)) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
585 'article-type 'annotation))))) |
17493 | 586 |
587 (defun gnus-article-hide-citation-maybe (&optional arg force) | |
588 "Toggle hiding of cited text that has an attribution line. | |
589 If given a negative prefix, always show; if given a positive prefix, | |
590 always hide. | |
591 This will do nothing unless at least `gnus-cite-hide-percentage' | |
592 percent and at least `gnus-cite-hide-absolute' lines of the body is | |
593 cited text with attributions. When called interactively, these two | |
594 variables are ignored. | |
595 See also the documentation for `gnus-article-highlight-citation'." | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
596 (interactive (append (gnus-article-hidden-arg) '(force))) |
17493 | 597 (unless (gnus-article-check-hidden-text 'cite arg) |
598 (save-excursion | |
599 (set-buffer gnus-article-buffer) | |
600 (gnus-cite-parse-maybe force) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
601 (article-goto-body) |
17493 | 602 (let ((start (point)) |
603 (atts gnus-cite-attribution-alist) | |
604 (buffer-read-only nil) | |
605 (inhibit-point-motion-hooks t) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
606 (hidden 0) |
17493 | 607 total) |
608 (goto-char (point-max)) | |
609 (gnus-article-search-signature) | |
610 (setq total (count-lines start (point))) | |
611 (while atts | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
612 (setq hidden (+ hidden (length (cdr (assoc (cdar atts) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
613 gnus-cite-prefix-alist)))) |
17493 | 614 atts (cdr atts))) |
615 (when (or force | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
616 (and (> (* 100 hidden) (* gnus-cite-hide-percentage total)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
617 (> hidden gnus-cite-hide-absolute))) |
17493 | 618 (setq atts gnus-cite-attribution-alist) |
619 (while atts | |
620 (setq total (cdr (assoc (cdar atts) gnus-cite-prefix-alist)) | |
621 atts (cdr atts)) | |
622 (while total | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
623 (setq hidden (car total) |
17493 | 624 total (cdr total)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
625 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
626 (forward-line (1- hidden)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
627 (unless (assq hidden gnus-cite-attribution-alist) |
17493 | 628 (gnus-add-text-properties |
629 (point) (progn (forward-line 1) (point)) | |
630 (nconc (list 'article-type 'cite) | |
631 gnus-hidden-properties)))))))))) | |
632 | |
633 (defun gnus-article-hide-citation-in-followups () | |
634 "Hide cited text in non-root articles." | |
635 (interactive) | |
636 (save-excursion | |
637 (set-buffer gnus-article-buffer) | |
638 (let ((article (cdr gnus-article-current))) | |
639 (unless (save-excursion | |
640 (set-buffer gnus-summary-buffer) | |
641 (gnus-article-displayed-root-p article)) | |
642 (gnus-article-hide-citation))))) | |
643 | |
644 ;;; Internal functions: | |
645 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
646 (defun gnus-cite-parse-maybe (&optional force no-overlay) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
647 "Always parse the buffer." |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
648 (gnus-cite-localize) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
649 ;;Reset parser information. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
650 (setq gnus-cite-prefix-alist nil |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
651 gnus-cite-attribution-alist nil |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
652 gnus-cite-loose-prefix-alist nil |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
653 gnus-cite-loose-attribution-alist nil) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
654 (unless no-overlay |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
655 (gnus-cite-delete-overlays)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
656 ;; Parse if not too large. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
657 (if (and gnus-cite-parse-max-size |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
658 (> (buffer-size) gnus-cite-parse-max-size)) |
17493 | 659 () |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
660 (setq gnus-cite-article (cons (car gnus-article-current) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
661 (cdr gnus-article-current))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
662 (gnus-cite-parse-wrapper))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
663 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
664 (defun gnus-cite-delete-overlays () |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
665 (dolist (overlay gnus-cite-overlay-list) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
666 (when (or (not (gnus-overlay-end overlay)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
667 (and (>= (gnus-overlay-end overlay) (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
668 (<= (gnus-overlay-end overlay) (point-max)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
669 (setq gnus-cite-overlay-list (delete overlay gnus-cite-overlay-list)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
670 (gnus-delete-overlay overlay)))) |
17493 | 671 |
672 (defun gnus-cite-parse-wrapper () | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
673 ;; Wrap chopped gnus-cite-parse. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
674 (article-goto-body) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
675 (let ((inhibit-point-motion-hooks t)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
676 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
677 (gnus-cite-parse-attributions)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
678 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
679 (gnus-cite-parse)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
680 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
681 (gnus-cite-connect-attributions)))) |
17493 | 682 |
683 (defun gnus-cite-parse () | |
684 ;; Parse and connect citation prefixes and attribution lines. | |
685 | |
686 ;; Parse current buffer searching for citation prefixes. | |
687 (let ((line (1+ (count-lines (point-min) (point)))) | |
688 (case-fold-search t) | |
689 (max (save-excursion | |
690 (goto-char (point-max)) | |
691 (gnus-article-search-signature) | |
692 (point))) | |
693 alist entry start begin end numbers prefix) | |
694 ;; Get all potential prefixes in `alist'. | |
695 (while (< (point) max) | |
696 ;; Each line. | |
697 (setq begin (point) | |
698 end (progn (beginning-of-line 2) (point)) | |
699 start end) | |
700 (goto-char begin) | |
701 ;; Ignore standard Supercite attribution prefix. | |
702 (when (looking-at gnus-supercite-regexp) | |
703 (if (match-end 1) | |
704 (setq end (1+ (match-end 1))) | |
705 (setq end (1+ begin)))) | |
706 ;; Ignore very long prefixes. | |
707 (when (> end (+ (point) gnus-cite-max-prefix)) | |
708 (setq end (+ (point) gnus-cite-max-prefix))) | |
709 (while (re-search-forward gnus-cite-prefix-regexp (1- end) t) | |
710 ;; Each prefix. | |
711 (setq end (match-end 0) | |
712 prefix (buffer-substring begin end)) | |
713 (gnus-set-text-properties 0 (length prefix) nil prefix) | |
714 (setq entry (assoc prefix alist)) | |
715 (if entry | |
716 (setcdr entry (cons line (cdr entry))) | |
717 (push (list prefix line) alist)) | |
718 (goto-char begin)) | |
719 (goto-char start) | |
720 (setq line (1+ line))) | |
721 ;; We got all the potential prefixes. Now create | |
722 ;; `gnus-cite-prefix-alist' containing the oldest prefix for each | |
723 ;; line that appears at least gnus-cite-minimum-match-count | |
724 ;; times. First sort them by length. Longer is older. | |
725 (setq alist (sort alist (lambda (a b) | |
726 (> (length (car a)) (length (car b)))))) | |
727 (while alist | |
728 (setq entry (car alist) | |
729 prefix (car entry) | |
730 numbers (cdr entry) | |
731 alist (cdr alist)) | |
732 (cond ((null numbers) | |
733 ;; No lines with this prefix that wasn't also part of | |
734 ;; a longer prefix. | |
735 ) | |
736 ((< (length numbers) gnus-cite-minimum-match-count) | |
737 ;; Too few lines with this prefix. We keep it a bit | |
738 ;; longer in case it is an exact match for an attribution | |
739 ;; line, but we don't remove the line from other | |
740 ;; prefixes. | |
741 (push entry gnus-cite-prefix-alist)) | |
742 (t | |
743 (push entry | |
744 gnus-cite-prefix-alist) | |
745 ;; Remove articles from other prefixes. | |
746 (let ((loop alist) | |
747 current) | |
748 (while loop | |
749 (setq current (car loop) | |
750 loop (cdr loop)) | |
751 (setcdr current | |
752 (gnus-set-difference (cdr current) numbers))))))))) | |
753 | |
754 (defun gnus-cite-parse-attributions () | |
755 (let (al-alist) | |
756 ;; Parse attributions | |
757 (while (re-search-forward gnus-cite-attribution-suffix (point-max) t) | |
758 (let* ((start (match-beginning 0)) | |
759 (end (match-end 0)) | |
760 (wrote (count-lines (point-min) end)) | |
761 (prefix (gnus-cite-find-prefix wrote)) | |
762 ;; Check previous line for an attribution leader. | |
763 (tag (progn | |
764 (beginning-of-line 1) | |
765 (when (looking-at gnus-supercite-secondary-regexp) | |
766 (buffer-substring (match-beginning 1) | |
767 (match-end 1))))) | |
768 (in (progn | |
769 (goto-char start) | |
770 (and (re-search-backward gnus-cite-attribution-prefix | |
771 (save-excursion | |
772 (beginning-of-line 0) | |
773 (point)) | |
774 t) | |
775 (not (re-search-forward gnus-cite-attribution-suffix | |
776 start t)) | |
777 (count-lines (point-min) (1+ (point))))))) | |
778 (when (eq wrote in) | |
779 (setq in nil)) | |
780 (goto-char end) | |
781 ;; don't add duplicates | |
782 (let ((al (buffer-substring (save-excursion (beginning-of-line 0) | |
783 (1+ (point))) | |
784 end))) | |
785 (if (not (assoc al al-alist)) | |
786 (progn | |
787 (push (list wrote in prefix tag) | |
788 gnus-cite-loose-attribution-alist) | |
789 (push (cons al t) al-alist)))))))) | |
790 | |
791 (defun gnus-cite-connect-attributions () | |
792 ;; Connect attributions to citations | |
793 | |
794 ;; No citations have been connected to attribution lines yet. | |
795 (setq gnus-cite-loose-prefix-alist (append gnus-cite-prefix-alist nil)) | |
796 | |
797 ;; Parse current buffer searching for attribution lines. | |
798 ;; Find exact supercite citations. | |
799 (gnus-cite-match-attributions 'small nil | |
800 (lambda (prefix tag) | |
801 (when tag | |
802 (concat "\\`" | |
803 (regexp-quote prefix) "[ \t]*" | |
804 (regexp-quote tag) ">")))) | |
805 ;; Find loose supercite citations after attributions. | |
806 (gnus-cite-match-attributions 'small t | |
807 (lambda (prefix tag) | |
808 (when tag | |
809 (concat "\\<" | |
810 (regexp-quote tag) | |
811 "\\>")))) | |
812 ;; Find loose supercite citations anywhere. | |
813 (gnus-cite-match-attributions 'small nil | |
814 (lambda (prefix tag) | |
815 (when tag | |
816 (concat "\\<" | |
817 (regexp-quote tag) | |
818 "\\>")))) | |
819 ;; Find nested citations after attributions. | |
820 (gnus-cite-match-attributions 'small-if-unique t | |
821 (lambda (prefix tag) | |
822 (concat "\\`" (regexp-quote prefix) ".+"))) | |
823 ;; Find nested citations anywhere. | |
824 (gnus-cite-match-attributions 'small nil | |
825 (lambda (prefix tag) | |
826 (concat "\\`" (regexp-quote prefix) ".+"))) | |
827 ;; Remove loose prefixes with too few lines. | |
828 (let ((alist gnus-cite-loose-prefix-alist) | |
829 entry) | |
830 (while alist | |
831 (setq entry (car alist) | |
832 alist (cdr alist)) | |
833 (when (< (length (cdr entry)) gnus-cite-minimum-match-count) | |
834 (setq gnus-cite-prefix-alist | |
835 (delq entry gnus-cite-prefix-alist) | |
836 gnus-cite-loose-prefix-alist | |
837 (delq entry gnus-cite-loose-prefix-alist))))) | |
838 ;; Find flat attributions. | |
839 (gnus-cite-match-attributions 'first t nil) | |
840 ;; Find any attributions (are we getting desperate yet?). | |
841 (gnus-cite-match-attributions 'first nil nil)) | |
842 | |
843 (defun gnus-cite-match-attributions (sort after fun) | |
844 ;; Match all loose attributions and citations (SORT AFTER FUN) . | |
845 ;; | |
846 ;; If SORT is `small', the citation with the shortest prefix will be | |
847 ;; used, if it is `first' the first prefix will be used, if it is | |
848 ;; `small-if-unique' the shortest prefix will be used if the | |
849 ;; attribution line does not share its own prefix with other | |
850 ;; loose attribution lines, otherwise the first prefix will be used. | |
851 ;; | |
852 ;; If AFTER is non-nil, only citations after the attribution line | |
853 ;; will be considered. | |
854 ;; | |
855 ;; If FUN is non-nil, it will be called with the arguments (WROTE | |
856 ;; PREFIX TAG) and expected to return a regular expression. Only | |
857 ;; citations whose prefix matches the regular expression will be | |
858 ;; considered. | |
859 ;; | |
860 ;; WROTE is the attribution line number. | |
861 ;; PREFIX is the attribution line prefix. | |
862 ;; TAG is the Supercite tag on the attribution line. | |
863 (let ((atts gnus-cite-loose-attribution-alist) | |
864 (case-fold-search t) | |
865 att wrote in prefix tag regexp limit smallest best size) | |
866 (while atts | |
867 (setq att (car atts) | |
868 atts (cdr atts) | |
869 wrote (nth 0 att) | |
870 in (nth 1 att) | |
871 prefix (nth 2 att) | |
872 tag (nth 3 att) | |
873 regexp (if fun (funcall fun prefix tag) "") | |
874 size (cond ((eq sort 'small) t) | |
875 ((eq sort 'first) nil) | |
876 (t (< (length (gnus-cite-find-loose prefix)) 2))) | |
877 limit (if after wrote -1) | |
878 smallest 1000000 | |
879 best nil) | |
880 (let ((cites gnus-cite-loose-prefix-alist) | |
881 cite candidate numbers first compare) | |
882 (while cites | |
883 (setq cite (car cites) | |
884 cites (cdr cites) | |
885 candidate (car cite) | |
886 numbers (cdr cite) | |
887 first (apply 'min numbers) | |
888 compare (if size (length candidate) first)) | |
889 (and (> first limit) | |
890 regexp | |
891 (string-match regexp candidate) | |
892 (< compare smallest) | |
893 (setq best cite | |
894 smallest compare)))) | |
895 (if (null best) | |
896 () | |
897 (setq gnus-cite-loose-attribution-alist | |
898 (delq att gnus-cite-loose-attribution-alist)) | |
899 (push (cons wrote (car best)) gnus-cite-attribution-alist) | |
900 (when in | |
901 (push (cons in (car best)) gnus-cite-attribution-alist)) | |
902 (when (memq best gnus-cite-loose-prefix-alist) | |
903 (let ((loop gnus-cite-prefix-alist) | |
904 (numbers (cdr best)) | |
905 current) | |
906 (setq gnus-cite-loose-prefix-alist | |
907 (delq best gnus-cite-loose-prefix-alist)) | |
908 (while loop | |
909 (setq current (car loop) | |
910 loop (cdr loop)) | |
911 (if (eq current best) | |
912 () | |
913 (setcdr current (gnus-set-difference (cdr current) numbers)) | |
914 (when (null (cdr current)) | |
915 (setq gnus-cite-loose-prefix-alist | |
916 (delq current gnus-cite-loose-prefix-alist) | |
917 atts (delq current atts))))))))))) | |
918 | |
919 (defun gnus-cite-find-loose (prefix) | |
920 ;; Return a list of loose attribution lines prefixed by PREFIX. | |
921 (let* ((atts gnus-cite-loose-attribution-alist) | |
922 att line lines) | |
923 (while atts | |
924 (setq att (car atts) | |
925 line (car att) | |
926 atts (cdr atts)) | |
927 (when (string-equal (gnus-cite-find-prefix line) prefix) | |
928 (push line lines))) | |
929 lines)) | |
930 | |
931 (defun gnus-cite-add-face (number prefix face) | |
932 ;; At line NUMBER, ignore PREFIX and add FACE to the rest of the line. | |
933 (when face | |
934 (let ((inhibit-point-motion-hooks t) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
935 from to overlay) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
936 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
937 (when (zerop (forward-line (1- number))) |
17493 | 938 (forward-char (length prefix)) |
939 (skip-chars-forward " \t") | |
940 (setq from (point)) | |
941 (end-of-line 1) | |
942 (skip-chars-backward " \t") | |
943 (setq to (point)) | |
944 (when (< from to) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
945 (push (setq overlay (gnus-make-overlay from to)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
946 gnus-cite-overlay-list) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
947 (gnus-overlay-put overlay 'face face)))))) |
17493 | 948 |
949 (defun gnus-cite-toggle (prefix) | |
950 (save-excursion | |
951 (set-buffer gnus-article-buffer) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
952 (gnus-cite-parse-maybe nil t) |
17493 | 953 (let ((buffer-read-only nil) |
954 (numbers (cdr (assoc prefix gnus-cite-prefix-alist))) | |
955 (inhibit-point-motion-hooks t) | |
956 number) | |
957 (while numbers | |
958 (setq number (car numbers) | |
959 numbers (cdr numbers)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
960 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
961 (forward-line (1- number)) |
17493 | 962 (cond ((get-text-property (point) 'invisible) |
963 (remove-text-properties (point) (progn (forward-line 1) (point)) | |
964 gnus-hidden-properties)) | |
965 ((assq number gnus-cite-attribution-alist)) | |
966 (t | |
967 (gnus-add-text-properties | |
968 (point) (progn (forward-line 1) (point)) | |
969 (nconc (list 'article-type 'cite) | |
970 gnus-hidden-properties)))))))) | |
971 | |
972 (defun gnus-cite-find-prefix (line) | |
973 ;; Return citation prefix for LINE. | |
974 (let ((alist gnus-cite-prefix-alist) | |
975 (prefix "") | |
976 entry) | |
977 (while alist | |
978 (setq entry (car alist) | |
979 alist (cdr alist)) | |
980 (when (memq line (cdr entry)) | |
981 (setq prefix (car entry)))) | |
982 prefix)) | |
983 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
984 (defun gnus-cite-localize () |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
985 "Make the citation variables local to the article buffer." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
986 (let ((vars '(gnus-cite-article |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
987 gnus-cite-overlay-list gnus-cite-prefix-alist |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
988 gnus-cite-attribution-alist gnus-cite-loose-prefix-alist |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
989 gnus-cite-loose-attribution-alist))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
990 (while vars |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
991 (make-local-variable (pop vars))))) |
17493 | 992 |
993 (gnus-ems-redefine) | |
994 | |
995 (provide 'gnus-cite) | |
996 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
997 ;; Local Variables: |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
998 ;; coding: iso-8859-1 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
999 ;; End: |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1000 |
52401 | 1001 ;;; arch-tag: 1997b044-6067-471e-8c8f-dc903093098a |
17493 | 1002 ;;; gnus-cite.el ends here |