annotate lisp/gnus/gnus-cite.el @ 16:0293115a14e9 r19-15b91

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