Mercurial > emacs
annotate lisp/gnus/gnus-cite.el @ 42706:be541feb06cc
Fix typo.
author | Pavel Janík <Pavel@Janik.cz> |
---|---|
date | Sun, 13 Jan 2002 10:09:20 +0000 |
parents | 1e4516b1d514 |
children | 79139aa0f18c |
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 | |
268 ;;; Internal Variables: | |
269 | |
270 (defvar gnus-cite-article nil) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
271 (defvar gnus-cite-overlay-list nil) |
17493 | 272 |
273 (defvar gnus-cite-prefix-alist nil) | |
274 ;; Alist of citation prefixes. | |
275 ;; The cdr is a list of lines with that prefix. | |
276 | |
277 (defvar gnus-cite-attribution-alist nil) | |
278 ;; Alist of attribution lines. | |
279 ;; The car is a line number. | |
280 ;; The cdr is the prefix for the citation started by that line. | |
281 | |
282 (defvar gnus-cite-loose-prefix-alist nil) | |
283 ;; Alist of citation prefixes that have no matching attribution. | |
284 ;; The cdr is a list of lines with that prefix. | |
285 | |
286 (defvar gnus-cite-loose-attribution-alist nil) | |
287 ;; Alist of attribution lines that have no matching citation. | |
288 ;; Each member has the form (WROTE IN PREFIX TAG), where | |
289 ;; WROTE: is the attribution line number | |
290 ;; IN: is the line number of the previous line if part of the same attribution, | |
291 ;; PREFIX: Is the citation prefix of the attribution line(s), and | |
292 ;; TAG: Is a Supercite tag, if any. | |
293 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
294 (defvar gnus-cited-opened-text-button-line-format-alist |
17493 | 295 `((?b (marker-position beg) ?d) |
296 (?e (marker-position end) ?d) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
297 (?n (count-lines beg end) ?d) |
17493 | 298 (?l (- end beg) ?d))) |
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-spec nil) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
300 (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
|
301 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
|
302 (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
|
303 |
17493 | 304 |
305 ;;; Commands: | |
306 | |
307 (defun gnus-article-highlight-citation (&optional force) | |
308 "Highlight cited text. | |
309 Each citation in the article will be highlighted with a different face. | |
310 The faces are taken from `gnus-cite-face-list'. | |
311 Attribution lines are highlighted with the same face as the | |
312 corresponding citation merged with `gnus-cite-attribution-face'. | |
313 | |
314 Text is considered cited if at least `gnus-cite-minimum-match-count' | |
315 lines matches `gnus-cite-prefix-regexp' with the same prefix. | |
316 | |
317 Lines matching `gnus-cite-attribution-suffix' and perhaps | |
318 `gnus-cite-attribution-prefix' are considered attribution lines." | |
319 (interactive (list 'force)) | |
320 (save-excursion | |
321 (set-buffer gnus-article-buffer) | |
322 (gnus-cite-parse-maybe force) | |
323 (let ((buffer-read-only nil) | |
324 (alist gnus-cite-prefix-alist) | |
325 (faces gnus-cite-face-list) | |
326 (inhibit-point-motion-hooks t) | |
327 face entry prefix skip numbers number face-alist) | |
328 ;; Loop through citation prefixes. | |
329 (while alist | |
330 (setq entry (car alist) | |
331 alist (cdr alist) | |
332 prefix (car entry) | |
333 numbers (cdr entry) | |
334 face (car faces) | |
335 faces (or (cdr faces) gnus-cite-face-list) | |
336 face-alist (cons (cons prefix face) face-alist)) | |
337 (while numbers | |
338 (setq number (car numbers) | |
339 numbers (cdr numbers)) | |
340 (and (not (assq number gnus-cite-attribution-alist)) | |
341 (not (assq number gnus-cite-loose-attribution-alist)) | |
342 (gnus-cite-add-face number prefix face)))) | |
343 ;; Loop through attribution lines. | |
344 (setq alist gnus-cite-attribution-alist) | |
345 (while alist | |
346 (setq entry (car alist) | |
347 alist (cdr alist) | |
348 number (car entry) | |
349 prefix (cdr entry) | |
350 skip (gnus-cite-find-prefix number) | |
351 face (cdr (assoc prefix face-alist))) | |
352 ;; Add attribution button. | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
353 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
354 (forward-line (1- number)) |
17493 | 355 (when (re-search-forward gnus-cite-attribution-suffix |
356 (save-excursion (end-of-line 1) (point)) | |
357 t) | |
358 (gnus-article-add-button (match-beginning 1) (match-end 1) | |
359 'gnus-cite-toggle prefix)) | |
360 ;; Highlight attribution line. | |
361 (gnus-cite-add-face number skip face) | |
362 (gnus-cite-add-face number skip gnus-cite-attribution-face)) | |
363 ;; Loop through attribution lines. | |
364 (setq alist gnus-cite-loose-attribution-alist) | |
365 (while alist | |
366 (setq entry (car alist) | |
367 alist (cdr alist) | |
368 number (car entry) | |
369 skip (gnus-cite-find-prefix number)) | |
370 (gnus-cite-add-face number skip gnus-cite-attribution-face))))) | |
371 | |
372 (defun gnus-dissect-cited-text () | |
373 "Dissect the article buffer looking for cited text." | |
374 (save-excursion | |
375 (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
|
376 (gnus-cite-parse-maybe nil t) |
17493 | 377 (let ((alist gnus-cite-prefix-alist) |
378 prefix numbers number marks m) | |
379 ;; Loop through citation prefixes. | |
380 (while alist | |
381 (setq numbers (pop alist) | |
382 prefix (pop numbers)) | |
383 (while numbers | |
384 (setq number (pop numbers)) | |
385 (goto-char (point-min)) | |
386 (forward-line number) | |
387 (push (cons (point-marker) "") marks) | |
388 (while (and numbers | |
389 (= (1- number) (car numbers))) | |
390 (setq number (pop numbers))) | |
391 (goto-char (point-min)) | |
392 (forward-line (1- number)) | |
393 (push (cons (point-marker) prefix) marks))) | |
394 ;; 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
|
395 (article-goto-body) |
17493 | 396 (push (cons (point-marker) "") marks) |
397 ;; Find the end of the body. | |
398 (goto-char (point-max)) | |
399 (gnus-article-search-signature) | |
400 (push (cons (point-marker) "") marks) | |
401 ;; Sort the marks. | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
402 (setq marks (sort marks 'car-less-than-car)) |
17493 | 403 (let ((omarks marks)) |
404 (setq marks nil) | |
405 (while (cdr omarks) | |
406 (if (= (caar omarks) (caadr omarks)) | |
407 (progn | |
408 (unless (equal (cdar omarks) "") | |
409 (push (car omarks) marks)) | |
410 (unless (equal (cdadr omarks) "") | |
411 (push (cadr omarks) marks)) | |
412 (unless (and (equal (cdar omarks) "") | |
413 (equal (cdadr omarks) "") | |
414 (not (cddr omarks))) | |
415 (setq omarks (cdr omarks)))) | |
416 (push (car omarks) marks)) | |
417 (setq omarks (cdr omarks))) | |
418 (when (car omarks) | |
419 (push (car omarks) marks)) | |
420 (setq marks (setq m (nreverse marks))) | |
421 (while (cddr m) | |
422 (if (and (equal (cdadr m) "") | |
423 (equal (cdar m) (cdaddr m)) | |
424 (goto-char (caadr m)) | |
425 (forward-line 1) | |
426 (= (point) (caaddr m))) | |
427 (setcdr m (cdddr m)) | |
428 (setq m (cdr m)))) | |
429 marks)))) | |
430 | |
431 (defun gnus-article-fill-cited-article (&optional force width) | |
432 "Do word wrapping in the current article. | |
433 If WIDTH (the numerical prefix), use that text width when filling." | |
434 (interactive (list t current-prefix-arg)) | |
435 (save-excursion | |
436 (set-buffer gnus-article-buffer) | |
437 (let ((buffer-read-only nil) | |
438 (inhibit-point-motion-hooks t) | |
439 (marks (gnus-dissect-cited-text)) | |
440 (adaptive-fill-mode nil) | |
441 (filladapt-mode nil) | |
442 (fill-column (if width (prefix-numeric-value width) fill-column))) | |
443 (save-restriction | |
444 (while (cdr marks) | |
445 (narrow-to-region (caar marks) (caadr marks)) | |
446 (let ((adaptive-fill-regexp | |
447 (concat "^" (regexp-quote (cdar marks)) " *")) | |
448 (fill-prefix (cdar marks))) | |
449 (fill-region (point-min) (point-max))) | |
450 (set-marker (caar marks) nil) | |
451 (setq marks (cdr marks))) | |
452 (when marks | |
453 (set-marker (caar marks) nil)) | |
454 ;; All this information is now incorrect. | |
455 (setq gnus-cite-prefix-alist nil | |
456 gnus-cite-attribution-alist nil | |
457 gnus-cite-loose-prefix-alist nil | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
458 gnus-cite-loose-attribution-alist nil |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
459 gnus-cite-article nil))))) |
17493 | 460 |
461 (defun gnus-article-hide-citation (&optional arg force) | |
462 "Toggle hiding of all cited text except attribution lines. | |
463 See the documentation for `gnus-article-highlight-citation'. | |
464 If given a negative prefix, always show; if given a positive prefix, | |
465 always hide." | |
466 (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
|
467 (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
|
468 (gnus-set-format 'cited-closed-text-button t) |
17493 | 469 (save-excursion |
470 (set-buffer gnus-article-buffer) | |
471 (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
|
472 marks |
17493 | 473 (inhibit-point-motion-hooks t) |
474 (props (nconc (list 'article-type 'cite) | |
475 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
|
476 (point (point-min)) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
477 found beg end start) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
478 (while (setq point |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
479 (text-property-any point (point-max) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
480 'gnus-callback |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
481 '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
|
482 (setq found t) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
483 (goto-char point) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
484 (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
|
485 (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
|
486 (forward-line 1) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
487 (setq point (point))) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
488 (unless found |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
489 (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
|
490 (while marks |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
491 (setq beg nil |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
492 end nil) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
493 (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
|
494 (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
|
495 (when 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 (caar marks))) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
497 (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
|
498 (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
|
499 (when marks |
17493 | 500 (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
|
501 ;; 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
|
502 (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
|
503 (goto-char beg) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
504 (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
|
505 (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
|
506 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
|
507 (if (>= (point) end) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
508 (setq beg nil) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
509 (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
|
510 (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
|
511 (goto-char end) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
512 (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
|
513 (if (<= (point) beg) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
514 (setq beg nil) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
515 (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
|
516 (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
|
517 ;; 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
|
518 ;; 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
|
519 (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
|
520 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
|
521 (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
|
522 (goto-char beg) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
523 (unless (save-excursion (search-backward "\n\n" nil t)) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
524 (insert "\n")) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
525 (put-text-property |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
526 (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
|
527 (progn |
17493 | 528 (gnus-article-add-button |
529 (point) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
530 (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
|
531 (point)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
532 `gnus-article-toggle-cited-text |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
533 (list (cons beg end) start)) |
17493 | 534 (point)) |
34727
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
535 'article-type 'annotation) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
536 (set-marker beg (point)))))))) |
17493 | 537 |
34727
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
538 (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
|
539 "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
|
540 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
|
541 means show, nil means toggle." |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
542 (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
|
543 (beg (car region)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
544 (end (cdr region)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
545 (start (cadr args)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
546 (hidden |
34727
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
547 (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
|
548 (inhibit-point-motion-hooks t) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
549 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
|
550 (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
|
551 (zerop arg) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
552 (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
|
553 (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
|
554 (if hidden |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
555 (gnus-remove-text-properties-when |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
556 'article-type 'cite beg end |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
557 (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
|
558 gnus-hidden-properties))) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
559 (gnus-add-text-properties-when |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
560 'article-type nil beg end |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
561 (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
|
562 gnus-hidden-properties)))) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
563 (save-excursion |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
564 (goto-char start) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
565 (gnus-delete-line) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
566 (put-text-property |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
567 (point) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
568 (progn |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
569 (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
|
570 (point) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
571 (progn (eval |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
572 (if hidden |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
573 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
|
574 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
|
575 (point)) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
576 `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
|
577 args) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
578 (point)) |
4b9a7a10deaa
* gnus-util.el (gnus-add-text-properties-when): New function.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33374
diff
changeset
|
579 'article-type 'annotation))))) |
17493 | 580 |
581 (defun gnus-article-hide-citation-maybe (&optional arg force) | |
582 "Toggle hiding of cited text that has an attribution line. | |
583 If given a negative prefix, always show; if given a positive prefix, | |
584 always hide. | |
585 This will do nothing unless at least `gnus-cite-hide-percentage' | |
586 percent and at least `gnus-cite-hide-absolute' lines of the body is | |
587 cited text with attributions. When called interactively, these two | |
588 variables are ignored. | |
589 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
|
590 (interactive (append (gnus-article-hidden-arg) '(force))) |
17493 | 591 (unless (gnus-article-check-hidden-text 'cite arg) |
592 (save-excursion | |
593 (set-buffer gnus-article-buffer) | |
594 (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
|
595 (article-goto-body) |
17493 | 596 (let ((start (point)) |
597 (atts gnus-cite-attribution-alist) | |
598 (buffer-read-only nil) | |
599 (inhibit-point-motion-hooks t) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
600 (hidden 0) |
17493 | 601 total) |
602 (goto-char (point-max)) | |
603 (gnus-article-search-signature) | |
604 (setq total (count-lines start (point))) | |
605 (while atts | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
606 (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
|
607 gnus-cite-prefix-alist)))) |
17493 | 608 atts (cdr atts))) |
609 (when (or force | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
610 (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
|
611 (> hidden gnus-cite-hide-absolute))) |
17493 | 612 (setq atts gnus-cite-attribution-alist) |
613 (while atts | |
614 (setq total (cdr (assoc (cdar atts) gnus-cite-prefix-alist)) | |
615 atts (cdr atts)) | |
616 (while total | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
617 (setq hidden (car total) |
17493 | 618 total (cdr total)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
619 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
620 (forward-line (1- hidden)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
621 (unless (assq hidden gnus-cite-attribution-alist) |
17493 | 622 (gnus-add-text-properties |
623 (point) (progn (forward-line 1) (point)) | |
624 (nconc (list 'article-type 'cite) | |
625 gnus-hidden-properties)))))))))) | |
626 | |
627 (defun gnus-article-hide-citation-in-followups () | |
628 "Hide cited text in non-root articles." | |
629 (interactive) | |
630 (save-excursion | |
631 (set-buffer gnus-article-buffer) | |
632 (let ((article (cdr gnus-article-current))) | |
633 (unless (save-excursion | |
634 (set-buffer gnus-summary-buffer) | |
635 (gnus-article-displayed-root-p article)) | |
636 (gnus-article-hide-citation))))) | |
637 | |
638 ;;; Internal functions: | |
639 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
640 (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
|
641 "Always parse the buffer." |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
642 (gnus-cite-localize) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
643 ;;Reset parser information. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
644 (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
|
645 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
|
646 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
|
647 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
|
648 (unless no-overlay |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
649 (gnus-cite-delete-overlays)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
650 ;; 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
|
651 (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
|
652 (> (buffer-size) gnus-cite-parse-max-size)) |
17493 | 653 () |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
654 (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
|
655 (cdr gnus-article-current))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
656 (gnus-cite-parse-wrapper))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
657 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
658 (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
|
659 (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
|
660 (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
|
661 (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
|
662 (<= (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
|
663 (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
|
664 (gnus-delete-overlay overlay)))) |
17493 | 665 |
666 (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
|
667 ;; 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
|
668 (article-goto-body) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
669 (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
|
670 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
671 (gnus-cite-parse-attributions)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
672 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
673 (gnus-cite-parse)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
674 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
675 (gnus-cite-connect-attributions)))) |
17493 | 676 |
677 (defun gnus-cite-parse () | |
678 ;; Parse and connect citation prefixes and attribution lines. | |
679 | |
680 ;; Parse current buffer searching for citation prefixes. | |
681 (let ((line (1+ (count-lines (point-min) (point)))) | |
682 (case-fold-search t) | |
683 (max (save-excursion | |
684 (goto-char (point-max)) | |
685 (gnus-article-search-signature) | |
686 (point))) | |
687 alist entry start begin end numbers prefix) | |
688 ;; Get all potential prefixes in `alist'. | |
689 (while (< (point) max) | |
690 ;; Each line. | |
691 (setq begin (point) | |
692 end (progn (beginning-of-line 2) (point)) | |
693 start end) | |
694 (goto-char begin) | |
695 ;; Ignore standard Supercite attribution prefix. | |
696 (when (looking-at gnus-supercite-regexp) | |
697 (if (match-end 1) | |
698 (setq end (1+ (match-end 1))) | |
699 (setq end (1+ begin)))) | |
700 ;; Ignore very long prefixes. | |
701 (when (> end (+ (point) gnus-cite-max-prefix)) | |
702 (setq end (+ (point) gnus-cite-max-prefix))) | |
703 (while (re-search-forward gnus-cite-prefix-regexp (1- end) t) | |
704 ;; Each prefix. | |
705 (setq end (match-end 0) | |
706 prefix (buffer-substring begin end)) | |
707 (gnus-set-text-properties 0 (length prefix) nil prefix) | |
708 (setq entry (assoc prefix alist)) | |
709 (if entry | |
710 (setcdr entry (cons line (cdr entry))) | |
711 (push (list prefix line) alist)) | |
712 (goto-char begin)) | |
713 (goto-char start) | |
714 (setq line (1+ line))) | |
715 ;; We got all the potential prefixes. Now create | |
716 ;; `gnus-cite-prefix-alist' containing the oldest prefix for each | |
717 ;; line that appears at least gnus-cite-minimum-match-count | |
718 ;; times. First sort them by length. Longer is older. | |
719 (setq alist (sort alist (lambda (a b) | |
720 (> (length (car a)) (length (car b)))))) | |
721 (while alist | |
722 (setq entry (car alist) | |
723 prefix (car entry) | |
724 numbers (cdr entry) | |
725 alist (cdr alist)) | |
726 (cond ((null numbers) | |
727 ;; No lines with this prefix that wasn't also part of | |
728 ;; a longer prefix. | |
729 ) | |
730 ((< (length numbers) gnus-cite-minimum-match-count) | |
731 ;; Too few lines with this prefix. We keep it a bit | |
732 ;; longer in case it is an exact match for an attribution | |
733 ;; line, but we don't remove the line from other | |
734 ;; prefixes. | |
735 (push entry gnus-cite-prefix-alist)) | |
736 (t | |
737 (push entry | |
738 gnus-cite-prefix-alist) | |
739 ;; Remove articles from other prefixes. | |
740 (let ((loop alist) | |
741 current) | |
742 (while loop | |
743 (setq current (car loop) | |
744 loop (cdr loop)) | |
745 (setcdr current | |
746 (gnus-set-difference (cdr current) numbers))))))))) | |
747 | |
748 (defun gnus-cite-parse-attributions () | |
749 (let (al-alist) | |
750 ;; Parse attributions | |
751 (while (re-search-forward gnus-cite-attribution-suffix (point-max) t) | |
752 (let* ((start (match-beginning 0)) | |
753 (end (match-end 0)) | |
754 (wrote (count-lines (point-min) end)) | |
755 (prefix (gnus-cite-find-prefix wrote)) | |
756 ;; Check previous line for an attribution leader. | |
757 (tag (progn | |
758 (beginning-of-line 1) | |
759 (when (looking-at gnus-supercite-secondary-regexp) | |
760 (buffer-substring (match-beginning 1) | |
761 (match-end 1))))) | |
762 (in (progn | |
763 (goto-char start) | |
764 (and (re-search-backward gnus-cite-attribution-prefix | |
765 (save-excursion | |
766 (beginning-of-line 0) | |
767 (point)) | |
768 t) | |
769 (not (re-search-forward gnus-cite-attribution-suffix | |
770 start t)) | |
771 (count-lines (point-min) (1+ (point))))))) | |
772 (when (eq wrote in) | |
773 (setq in nil)) | |
774 (goto-char end) | |
775 ;; don't add duplicates | |
776 (let ((al (buffer-substring (save-excursion (beginning-of-line 0) | |
777 (1+ (point))) | |
778 end))) | |
779 (if (not (assoc al al-alist)) | |
780 (progn | |
781 (push (list wrote in prefix tag) | |
782 gnus-cite-loose-attribution-alist) | |
783 (push (cons al t) al-alist)))))))) | |
784 | |
785 (defun gnus-cite-connect-attributions () | |
786 ;; Connect attributions to citations | |
787 | |
788 ;; No citations have been connected to attribution lines yet. | |
789 (setq gnus-cite-loose-prefix-alist (append gnus-cite-prefix-alist nil)) | |
790 | |
791 ;; Parse current buffer searching for attribution lines. | |
792 ;; Find exact supercite citations. | |
793 (gnus-cite-match-attributions 'small nil | |
794 (lambda (prefix tag) | |
795 (when tag | |
796 (concat "\\`" | |
797 (regexp-quote prefix) "[ \t]*" | |
798 (regexp-quote tag) ">")))) | |
799 ;; Find loose supercite citations after attributions. | |
800 (gnus-cite-match-attributions 'small t | |
801 (lambda (prefix tag) | |
802 (when tag | |
803 (concat "\\<" | |
804 (regexp-quote tag) | |
805 "\\>")))) | |
806 ;; Find loose supercite citations anywhere. | |
807 (gnus-cite-match-attributions 'small nil | |
808 (lambda (prefix tag) | |
809 (when tag | |
810 (concat "\\<" | |
811 (regexp-quote tag) | |
812 "\\>")))) | |
813 ;; Find nested citations after attributions. | |
814 (gnus-cite-match-attributions 'small-if-unique t | |
815 (lambda (prefix tag) | |
816 (concat "\\`" (regexp-quote prefix) ".+"))) | |
817 ;; Find nested citations anywhere. | |
818 (gnus-cite-match-attributions 'small nil | |
819 (lambda (prefix tag) | |
820 (concat "\\`" (regexp-quote prefix) ".+"))) | |
821 ;; Remove loose prefixes with too few lines. | |
822 (let ((alist gnus-cite-loose-prefix-alist) | |
823 entry) | |
824 (while alist | |
825 (setq entry (car alist) | |
826 alist (cdr alist)) | |
827 (when (< (length (cdr entry)) gnus-cite-minimum-match-count) | |
828 (setq gnus-cite-prefix-alist | |
829 (delq entry gnus-cite-prefix-alist) | |
830 gnus-cite-loose-prefix-alist | |
831 (delq entry gnus-cite-loose-prefix-alist))))) | |
832 ;; Find flat attributions. | |
833 (gnus-cite-match-attributions 'first t nil) | |
834 ;; Find any attributions (are we getting desperate yet?). | |
835 (gnus-cite-match-attributions 'first nil nil)) | |
836 | |
837 (defun gnus-cite-match-attributions (sort after fun) | |
838 ;; Match all loose attributions and citations (SORT AFTER FUN) . | |
839 ;; | |
840 ;; If SORT is `small', the citation with the shortest prefix will be | |
841 ;; used, if it is `first' the first prefix will be used, if it is | |
842 ;; `small-if-unique' the shortest prefix will be used if the | |
843 ;; attribution line does not share its own prefix with other | |
844 ;; loose attribution lines, otherwise the first prefix will be used. | |
845 ;; | |
846 ;; If AFTER is non-nil, only citations after the attribution line | |
847 ;; will be considered. | |
848 ;; | |
849 ;; If FUN is non-nil, it will be called with the arguments (WROTE | |
850 ;; PREFIX TAG) and expected to return a regular expression. Only | |
851 ;; citations whose prefix matches the regular expression will be | |
852 ;; considered. | |
853 ;; | |
854 ;; WROTE is the attribution line number. | |
855 ;; PREFIX is the attribution line prefix. | |
856 ;; TAG is the Supercite tag on the attribution line. | |
857 (let ((atts gnus-cite-loose-attribution-alist) | |
858 (case-fold-search t) | |
859 att wrote in prefix tag regexp limit smallest best size) | |
860 (while atts | |
861 (setq att (car atts) | |
862 atts (cdr atts) | |
863 wrote (nth 0 att) | |
864 in (nth 1 att) | |
865 prefix (nth 2 att) | |
866 tag (nth 3 att) | |
867 regexp (if fun (funcall fun prefix tag) "") | |
868 size (cond ((eq sort 'small) t) | |
869 ((eq sort 'first) nil) | |
870 (t (< (length (gnus-cite-find-loose prefix)) 2))) | |
871 limit (if after wrote -1) | |
872 smallest 1000000 | |
873 best nil) | |
874 (let ((cites gnus-cite-loose-prefix-alist) | |
875 cite candidate numbers first compare) | |
876 (while cites | |
877 (setq cite (car cites) | |
878 cites (cdr cites) | |
879 candidate (car cite) | |
880 numbers (cdr cite) | |
881 first (apply 'min numbers) | |
882 compare (if size (length candidate) first)) | |
883 (and (> first limit) | |
884 regexp | |
885 (string-match regexp candidate) | |
886 (< compare smallest) | |
887 (setq best cite | |
888 smallest compare)))) | |
889 (if (null best) | |
890 () | |
891 (setq gnus-cite-loose-attribution-alist | |
892 (delq att gnus-cite-loose-attribution-alist)) | |
893 (push (cons wrote (car best)) gnus-cite-attribution-alist) | |
894 (when in | |
895 (push (cons in (car best)) gnus-cite-attribution-alist)) | |
896 (when (memq best gnus-cite-loose-prefix-alist) | |
897 (let ((loop gnus-cite-prefix-alist) | |
898 (numbers (cdr best)) | |
899 current) | |
900 (setq gnus-cite-loose-prefix-alist | |
901 (delq best gnus-cite-loose-prefix-alist)) | |
902 (while loop | |
903 (setq current (car loop) | |
904 loop (cdr loop)) | |
905 (if (eq current best) | |
906 () | |
907 (setcdr current (gnus-set-difference (cdr current) numbers)) | |
908 (when (null (cdr current)) | |
909 (setq gnus-cite-loose-prefix-alist | |
910 (delq current gnus-cite-loose-prefix-alist) | |
911 atts (delq current atts))))))))))) | |
912 | |
913 (defun gnus-cite-find-loose (prefix) | |
914 ;; Return a list of loose attribution lines prefixed by PREFIX. | |
915 (let* ((atts gnus-cite-loose-attribution-alist) | |
916 att line lines) | |
917 (while atts | |
918 (setq att (car atts) | |
919 line (car att) | |
920 atts (cdr atts)) | |
921 (when (string-equal (gnus-cite-find-prefix line) prefix) | |
922 (push line lines))) | |
923 lines)) | |
924 | |
925 (defun gnus-cite-add-face (number prefix face) | |
926 ;; At line NUMBER, ignore PREFIX and add FACE to the rest of the line. | |
927 (when face | |
928 (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
|
929 from to overlay) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
930 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
931 (when (zerop (forward-line (1- number))) |
17493 | 932 (forward-char (length prefix)) |
933 (skip-chars-forward " \t") | |
934 (setq from (point)) | |
935 (end-of-line 1) | |
936 (skip-chars-backward " \t") | |
937 (setq to (point)) | |
938 (when (< from to) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
939 (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
|
940 gnus-cite-overlay-list) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
941 (gnus-overlay-put overlay 'face face)))))) |
17493 | 942 |
943 (defun gnus-cite-toggle (prefix) | |
944 (save-excursion | |
945 (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
|
946 (gnus-cite-parse-maybe nil t) |
17493 | 947 (let ((buffer-read-only nil) |
948 (numbers (cdr (assoc prefix gnus-cite-prefix-alist))) | |
949 (inhibit-point-motion-hooks t) | |
950 number) | |
951 (while numbers | |
952 (setq number (car numbers) | |
953 numbers (cdr numbers)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
954 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
955 (forward-line (1- number)) |
17493 | 956 (cond ((get-text-property (point) 'invisible) |
957 (remove-text-properties (point) (progn (forward-line 1) (point)) | |
958 gnus-hidden-properties)) | |
959 ((assq number gnus-cite-attribution-alist)) | |
960 (t | |
961 (gnus-add-text-properties | |
962 (point) (progn (forward-line 1) (point)) | |
963 (nconc (list 'article-type 'cite) | |
964 gnus-hidden-properties)))))))) | |
965 | |
966 (defun gnus-cite-find-prefix (line) | |
967 ;; Return citation prefix for LINE. | |
968 (let ((alist gnus-cite-prefix-alist) | |
969 (prefix "") | |
970 entry) | |
971 (while alist | |
972 (setq entry (car alist) | |
973 alist (cdr alist)) | |
974 (when (memq line (cdr entry)) | |
975 (setq prefix (car entry)))) | |
976 prefix)) | |
977 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
978 (defun gnus-cite-localize () |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
979 "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
|
980 (let ((vars '(gnus-cite-article |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
981 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
|
982 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
|
983 gnus-cite-loose-attribution-alist))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
984 (while vars |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
985 (make-local-variable (pop vars))))) |
17493 | 986 |
987 (gnus-ems-redefine) | |
988 | |
989 (provide 'gnus-cite) | |
990 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
991 ;; Local Variables: |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
992 ;; coding: iso-8859-1 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
993 ;; End: |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
994 |
17493 | 995 ;;; gnus-cite.el ends here |