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