Mercurial > emacs
annotate lisp/gnus/gnus-score.el @ 99409:aca04343781b
(cl-macroexpand-all): Declare.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Thu, 06 Nov 2008 03:53:43 +0000 |
parents | 1f27a4bf06f5 |
children | c663881a61c6 |
rev | line source |
---|---|
22386 | 1 ;;; gnus-score.el --- scoring code for Gnus |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
2 |
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, |
79708 | 4 ;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
17493 | 5 |
6 ;; Author: Per Abrahamsen <amanda@iesd.auc.dk> | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
7 ;; Lars Magne Ingebrigtsen <larsi@gnus.org> |
17493 | 8 ;; Keywords: news |
9 | |
10 ;; This file is part of GNU Emacs. | |
11 | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
17493 | 13 ;; it under the terms of the GNU General Public License as published by |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; (at your option) any later version. |
17493 | 16 |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
17493 | 24 |
25 ;;; Commentary: | |
26 | |
27 ;;; Code: | |
28 | |
19521
6f6cf9184e93
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
29 (eval-when-compile (require 'cl)) |
6f6cf9184e93
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
30 |
17493 | 31 (require 'gnus) |
32 (require 'gnus-sum) | |
33 (require 'gnus-range) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
34 (require 'gnus-win) |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
35 (require 'message) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
36 (require 'score-mode) |
17493 | 37 |
38 (defcustom gnus-global-score-files nil | |
39 "List of global score files and directories. | |
40 Set this variable if you want to use people's score files. One entry | |
41 for each score file or each score file directory. Gnus will decide | |
42 by itself what score files are applicable to which group. | |
43 | |
44 Say you want to use the single score file | |
45 \"/ftp.gnus.org@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all | |
46 score files in the \"/ftp.some-where:/pub/score\" directory. | |
47 | |
48 (setq gnus-global-score-files | |
49 '(\"/ftp.gnus.org:/pub/larsi/ding/score/soc.motss.SCORE\" | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
50 \"/ftp.some-where:/pub/score\"))" |
17493 | 51 :group 'gnus-score-files |
52 :type '(repeat file)) | |
53 | |
54 (defcustom gnus-score-file-single-match-alist nil | |
55 "Alist mapping regexps to lists of score files. | |
56 Each element of this alist should be of the form | |
57 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... ) | |
58 | |
59 If the name of a group is matched by REGEXP, the corresponding scorefiles | |
60 will be used for that group. | |
61 The first match found is used, subsequent matching entries are ignored (to | |
41059
70987a4f43c8
Fixed some doc strings to properly quote symbols.
Sam Steingold <sds@gnu.org>
parents:
35978
diff
changeset
|
62 use multiple matches, see `gnus-score-file-multiple-match-alist'). |
17493 | 63 |
64 These score files are loaded in addition to any files returned by | |
41059
70987a4f43c8
Fixed some doc strings to properly quote symbols.
Sam Steingold <sds@gnu.org>
parents:
35978
diff
changeset
|
65 `gnus-score-find-score-files-function'." |
17493 | 66 :group 'gnus-score-files |
67 :type '(repeat (cons regexp (repeat file)))) | |
68 | |
69 (defcustom gnus-score-file-multiple-match-alist nil | |
70 "Alist mapping regexps to lists of score files. | |
71 Each element of this alist should be of the form | |
72 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... ) | |
73 | |
74 If the name of a group is matched by REGEXP, the corresponding scorefiles | |
75 will be used for that group. | |
76 If multiple REGEXPs match a group, the score files corresponding to each | |
77 match will be used (for only one match to be used, see | |
41059
70987a4f43c8
Fixed some doc strings to properly quote symbols.
Sam Steingold <sds@gnu.org>
parents:
35978
diff
changeset
|
78 `gnus-score-file-single-match-alist'). |
17493 | 79 |
80 These score files are loaded in addition to any files returned by | |
41059
70987a4f43c8
Fixed some doc strings to properly quote symbols.
Sam Steingold <sds@gnu.org>
parents:
35978
diff
changeset
|
81 `gnus-score-find-score-files-function'." |
17493 | 82 :group 'gnus-score-files |
83 :type '(repeat (cons regexp (repeat file)))) | |
84 | |
85 (defcustom gnus-score-file-suffix "SCORE" | |
86 "Suffix of the score files." | |
87 :group 'gnus-score-files | |
88 :type 'string) | |
89 | |
90 (defcustom gnus-adaptive-file-suffix "ADAPT" | |
91 "Suffix of the adaptive score files." | |
92 :group 'gnus-score-files | |
93 :group 'gnus-score-adapt | |
94 :type 'string) | |
95 | |
96 (defcustom gnus-score-find-score-files-function 'gnus-score-find-bnews | |
97 "Function used to find score files. | |
98 The function will be called with the group name as the argument, and | |
99 should return a list of score files to apply to that group. The score | |
100 files do not actually have to exist. | |
101 | |
102 Predefined values are: | |
103 | |
41059
70987a4f43c8
Fixed some doc strings to properly quote symbols.
Sam Steingold <sds@gnu.org>
parents:
35978
diff
changeset
|
104 `gnus-score-find-single': Only apply the group's own score file. |
70987a4f43c8
Fixed some doc strings to properly quote symbols.
Sam Steingold <sds@gnu.org>
parents:
35978
diff
changeset
|
105 `gnus-score-find-hierarchical': Also apply score files from parent groups. |
70987a4f43c8
Fixed some doc strings to properly quote symbols.
Sam Steingold <sds@gnu.org>
parents:
35978
diff
changeset
|
106 `gnus-score-find-bnews': Apply score files whose names matches. |
17493 | 107 |
108 See the documentation to these functions for more information. | |
109 | |
110 This variable can also be a list of functions to be called. Each | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
111 function is given the group name as argument and should either return |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
112 a list of score files, or a list of score alists. |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
113 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
114 If functions other than these pre-defined functions are used, |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
115 the `a' symbolic prefix to the score commands will always use |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
116 \"all.SCORE\"." |
17493 | 117 :group 'gnus-score-files |
118 :type '(radio (function-item gnus-score-find-single) | |
119 (function-item gnus-score-find-hierarchical) | |
120 (function-item gnus-score-find-bnews) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
121 (repeat :tag "List of functions" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
122 (choice (function :tag "Other" :value 'ignore) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
123 (function-item gnus-score-find-single) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
124 (function-item gnus-score-find-hierarchical) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
125 (function-item gnus-score-find-bnews))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
126 (function :tag "Other" :value 'ignore))) |
17493 | 127 |
128 (defcustom gnus-score-interactive-default-score 1000 | |
129 "*Scoring commands will raise/lower the score with this number as the default." | |
130 :group 'gnus-score-default | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
131 :type 'integer) |
17493 | 132 |
133 (defcustom gnus-score-expiry-days 7 | |
134 "*Number of days before unused score file entries are expired. | |
135 If this variable is nil, no score file entries will be expired." | |
136 :group 'gnus-score-expire | |
137 :type '(choice (const :tag "never" nil) | |
138 number)) | |
139 | |
140 (defcustom gnus-update-score-entry-dates t | |
66808
a93385a3e7a2
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-646
Miles Bader <miles@gnu.org>
parents:
66454
diff
changeset
|
141 "*If non-nil, update matching score entry dates. |
17493 | 142 If this variable is nil, then score entries that provide matches |
143 will be expired along with non-matching score entries." | |
144 :group 'gnus-score-expire | |
145 :type 'boolean) | |
146 | |
147 (defcustom gnus-decay-scores nil | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
148 "*If non-nil, decay non-permanent scores. |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
149 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
150 If it is a regexp, only decay score files matching regexp." |
17493 | 151 :group 'gnus-score-decay |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
152 :type `(choice (const :tag "never" nil) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
153 (const :tag "always" t) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
154 (const :tag "adaptive score files" |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
155 ,(concat "\\." gnus-adaptive-file-suffix "\\'")) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
156 (regexp))) |
17493 | 157 |
158 (defcustom gnus-decay-score-function 'gnus-decay-score | |
159 "*Function called to decay a score. | |
160 It is called with one parameter -- the score to be decayed." | |
161 :group 'gnus-score-decay | |
162 :type '(radio (function-item gnus-decay-score) | |
163 (function :tag "Other"))) | |
164 | |
165 (defcustom gnus-score-decay-constant 3 | |
166 "*Decay all \"small\" scores with this amount." | |
167 :group 'gnus-score-decay | |
168 :type 'integer) | |
169 | |
170 (defcustom gnus-score-decay-scale .05 | |
171 "*Decay all \"big\" scores with this factor." | |
172 :group 'gnus-score-decay | |
173 :type 'number) | |
174 | |
175 (defcustom gnus-home-score-file nil | |
176 "Variable to control where interactive score entries are to go. | |
177 It can be: | |
178 | |
179 * A string | |
66808
a93385a3e7a2
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-646
Miles Bader <miles@gnu.org>
parents:
66454
diff
changeset
|
180 This file will be used as the home score file. |
17493 | 181 |
182 * A function | |
183 The result of this function will be used as the home score file. | |
184 The function will be passed the name of the group as its | |
185 parameter. | |
186 | |
187 * A list | |
188 The elements in this list can be: | |
189 | |
190 * `(regexp file-name ...)' | |
66808
a93385a3e7a2
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-646
Miles Bader <miles@gnu.org>
parents:
66454
diff
changeset
|
191 If the `regexp' matches the group name, the first `file-name' |
17493 | 192 will be used as the home score file. (Multiple filenames are |
193 allowed so that one may use gnus-score-file-single-match-alist to | |
194 set this variable.) | |
195 | |
196 * A function. | |
197 If the function returns non-nil, the result will be used | |
198 as the home score file. The function will be passed the | |
199 name of the group as its parameter. | |
200 | |
201 * A string. Use the string as the home score file. | |
202 | |
203 The list will be traversed from the beginning towards the end looking | |
204 for matches." | |
205 :group 'gnus-score-files | |
206 :type '(choice string | |
207 (repeat (choice string | |
208 (cons regexp (repeat file)) | |
75401 | 209 function)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
210 (function-item gnus-hierarchial-home-score-file) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
211 (function-item gnus-current-home-score-file) |
75401 | 212 function)) |
17493 | 213 |
214 (defcustom gnus-home-adapt-file nil | |
215 "Variable to control where new adaptive score entries are to go. | |
216 This variable allows the same syntax as `gnus-home-score-file'." | |
217 :group 'gnus-score-adapt | |
218 :group 'gnus-score-files | |
219 :type '(choice string | |
220 (repeat (choice string | |
221 (cons regexp (repeat file)) | |
75401 | 222 function)) |
223 function)) | |
17493 | 224 |
225 (defcustom gnus-default-adaptive-score-alist | |
66454
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
65682
diff
changeset
|
226 `((gnus-kill-file-mark) |
17493 | 227 (gnus-unread-mark) |
66454
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
65682
diff
changeset
|
228 (gnus-read-mark |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
65682
diff
changeset
|
229 (from , (+ 2 gnus-score-decay-constant)) |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
65682
diff
changeset
|
230 (subject , (+ 27 gnus-score-decay-constant))) |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
65682
diff
changeset
|
231 (gnus-catchup-mark |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
65682
diff
changeset
|
232 (subject , (+ -7 (* -1 gnus-score-decay-constant)))) |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
65682
diff
changeset
|
233 (gnus-killed-mark |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
65682
diff
changeset
|
234 (from , (- -1 gnus-score-decay-constant)) |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
65682
diff
changeset
|
235 (subject , (+ -17 (* -1 gnus-score-decay-constant)))) |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
65682
diff
changeset
|
236 (gnus-del-mark |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
65682
diff
changeset
|
237 (from , (- -1 gnus-score-decay-constant)) |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
65682
diff
changeset
|
238 (subject , (+ -12 (* -1 gnus-score-decay-constant))))) |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
65682
diff
changeset
|
239 "Alist of marks and scores. |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
65682
diff
changeset
|
240 If you use score decays, you might want to set values higher than |
9082bf778ad8
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
65682
diff
changeset
|
241 `gnus-score-decay-constant'." |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
242 :group 'gnus-score-adapt |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
243 :type '(repeat (cons (symbol :tag "Mark") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
244 (repeat (list (choice :tag "Header" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
245 (const from) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
246 (const subject) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
247 (symbol :tag "other")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
248 (integer :tag "Score")))))) |
17493 | 249 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
250 (defcustom gnus-adaptive-word-length-limit nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
251 "*Words of a length lesser than this limit will be ignored when doing adaptive scoring." |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
58835
diff
changeset
|
252 :version "22.1" |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
253 :group 'gnus-score-adapt |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
254 :type '(radio (const :format "Unlimited " nil) |
58835
9bdd97960431
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-716
Miles Bader <miles@gnu.org>
parents:
57153
diff
changeset
|
255 (integer :format "Maximum length: %v"))) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
256 |
17493 | 257 (defcustom gnus-ignored-adaptive-words nil |
258 "List of words to be ignored when doing adaptive word scoring." | |
259 :group 'gnus-score-adapt | |
260 :type '(repeat string)) | |
261 | |
262 (defcustom gnus-default-ignored-adaptive-words | |
263 '("a" "i" "the" "to" "of" "and" "in" "is" "it" "for" "that" "if" "you" | |
264 "this" "be" "on" "with" "not" "have" "are" "or" "as" "from" "can" | |
265 "but" "by" "at" "an" "will" "no" "all" "was" "do" "there" "my" "one" | |
266 "so" "we" "they" "what" "would" "any" "which" "about" "get" "your" | |
267 "use" "some" "me" "then" "name" "like" "out" "when" "up" "time" | |
268 "other" "more" "only" "just" "end" "also" "know" "how" "new" "should" | |
269 "been" "than" "them" "he" "who" "make" "may" "people" "these" "now" | |
270 "their" "here" "into" "first" "could" "way" "had" "see" "work" "well" | |
271 "were" "two" "very" "where" "while" "us" "because" "good" "same" | |
272 "even" "much" "most" "many" "such" "long" "his" "over" "last" "since" | |
273 "right" "before" "our" "without" "too" "those" "why" "must" "part" | |
274 "being" "current" "back" "still" "go" "point" "value" "each" "did" | |
275 "both" "true" "off" "say" "another" "state" "might" "under" "start" | |
276 "try" "re") | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
277 "*Default list of words to be ignored when doing adaptive word scoring." |
17493 | 278 :group 'gnus-score-adapt |
279 :type '(repeat string)) | |
280 | |
281 (defcustom gnus-default-adaptive-word-score-alist | |
282 `((,gnus-read-mark . 30) | |
283 (,gnus-catchup-mark . -10) | |
284 (,gnus-killed-mark . -20) | |
285 (,gnus-del-mark . -15)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
286 "*Alist of marks and scores." |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
287 :group 'gnus-score-adapt |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
288 :type '(repeat (cons (character :tag "Mark") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
289 (integer :tag "Score")))) |
17493 | 290 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
291 (defcustom gnus-adaptive-word-minimum nil |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
292 "If a number, this is the minimum score value that can be assigned to a word." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
293 :group 'gnus-score-adapt |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
294 :type '(choice (const nil) integer)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
295 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
296 (defcustom gnus-adaptive-word-no-group-words nil |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
297 "If t, don't adaptively score words included in the group name." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
298 :group 'gnus-score-adapt |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
299 :type 'boolean) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
300 |
17493 | 301 (defcustom gnus-score-mimic-keymap nil |
302 "*Have the score entry functions pretend that they are a keymap." | |
303 :group 'gnus-score-default | |
304 :type 'boolean) | |
305 | |
306 (defcustom gnus-score-exact-adapt-limit 10 | |
307 "*Number that says how long a match has to be before using substring matching. | |
308 When doing adaptive scoring, one normally uses fuzzy or substring | |
309 matching. However, if the header one matches is short, the possibility | |
310 for false positives is great, so if the length of the match is less | |
311 than this variable, exact matching will be used. | |
312 | |
313 If this variable is nil, exact matching will always be used." | |
314 :group 'gnus-score-adapt | |
315 :type '(choice (const nil) integer)) | |
316 | |
317 (defcustom gnus-score-uncacheable-files "ADAPT$" | |
318 "All score files that match this regexp will not be cached." | |
319 :group 'gnus-score-adapt | |
320 :group 'gnus-score-files | |
321 :type 'regexp) | |
322 | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
323 (defcustom gnus-adaptive-pretty-print nil |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
324 "If non-nil, adaptive score files fill are pretty printed." |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
325 :group 'gnus-score-files |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
326 :group 'gnus-score-adapt |
92336
5f827896103e
Change defcustom :version from 23.0 to 23.1.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
327 :version "23.1" ;; No Gnus |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
328 :type 'boolean) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
329 |
17493 | 330 (defcustom gnus-score-default-header nil |
331 "Default header when entering new scores. | |
332 | |
333 Should be one of the following symbols. | |
334 | |
335 a: from | |
336 s: subject | |
337 b: body | |
338 h: head | |
339 i: message-id | |
340 t: references | |
341 x: xref | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
342 e: `extra' (non-standard overview) |
17493 | 343 l: lines |
344 d: date | |
345 f: followup | |
346 | |
347 If nil, the user will be asked for a header." | |
348 :group 'gnus-score-default | |
349 :type '(choice (const :tag "from" a) | |
350 (const :tag "subject" s) | |
351 (const :tag "body" b) | |
352 (const :tag "head" h) | |
353 (const :tag "message-id" i) | |
354 (const :tag "references" t) | |
355 (const :tag "xref" x) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
356 (const :tag "extra" e) |
17493 | 357 (const :tag "lines" l) |
358 (const :tag "date" d) | |
23362
4882e505ccbc
(gnus-orphan-score, gnus-score-default-header, gnus-score-default-type):
Karl Heuer <kwzh@gnu.org>
parents:
22386
diff
changeset
|
359 (const :tag "followup" f) |
4882e505ccbc
(gnus-orphan-score, gnus-score-default-header, gnus-score-default-type):
Karl Heuer <kwzh@gnu.org>
parents:
22386
diff
changeset
|
360 (const :tag "ask" nil))) |
17493 | 361 |
362 (defcustom gnus-score-default-type nil | |
363 "Default match type when entering new scores. | |
364 | |
365 Should be one of the following symbols. | |
366 | |
367 s: substring | |
368 e: exact string | |
369 f: fuzzy string | |
370 r: regexp string | |
371 b: before date | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
372 a: after date |
17493 | 373 n: this date |
374 <: less than number | |
375 >: greater than number | |
376 =: equal to number | |
377 | |
378 If nil, the user will be asked for a match type." | |
379 :group 'gnus-score-default | |
380 :type '(choice (const :tag "substring" s) | |
381 (const :tag "exact string" e) | |
382 (const :tag "fuzzy string" f) | |
383 (const :tag "regexp string" r) | |
384 (const :tag "before date" b) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
385 (const :tag "after date" a) |
17493 | 386 (const :tag "this date" n) |
387 (const :tag "less than number" <) | |
388 (const :tag "greater than number" >) | |
23362
4882e505ccbc
(gnus-orphan-score, gnus-score-default-header, gnus-score-default-type):
Karl Heuer <kwzh@gnu.org>
parents:
22386
diff
changeset
|
389 (const :tag "equal than number" =) |
4882e505ccbc
(gnus-orphan-score, gnus-score-default-header, gnus-score-default-type):
Karl Heuer <kwzh@gnu.org>
parents:
22386
diff
changeset
|
390 (const :tag "ask" nil))) |
17493 | 391 |
392 (defcustom gnus-score-default-fold nil | |
78486
f0a07da7dd45
Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents:
78224
diff
changeset
|
393 "Non-nil means use case folding for new score file entries." |
17493 | 394 :group 'gnus-score-default |
395 :type 'boolean) | |
396 | |
397 (defcustom gnus-score-default-duration nil | |
398 "Default duration of effect when entering new scores. | |
399 | |
400 Should be one of the following symbols. | |
401 | |
402 t: temporary | |
403 p: permanent | |
404 i: immediate | |
405 | |
406 If nil, the user will be asked for a duration." | |
407 :group 'gnus-score-default | |
408 :type '(choice (const :tag "temporary" t) | |
409 (const :tag "permanent" p) | |
410 (const :tag "immediate" i) | |
411 (const :tag "ask" nil))) | |
412 | |
413 (defcustom gnus-score-after-write-file-function nil | |
414 "Function called with the name of the score file just written to disk." | |
415 :group 'gnus-score-files | |
35978
ea17c28c6476
(gnus-score-after-write-file-function): Fix :type.
Dave Love <fx@gnu.org>
parents:
35838
diff
changeset
|
416 :type '(choice (const nil) function)) |
17493 | 417 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
418 (defcustom gnus-score-thread-simplify nil |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
419 "If non-nil, subjects will simplified as in threading." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
420 :group 'gnus-score-various |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
421 :type 'boolean) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
422 |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
423 (defcustom gnus-inhibit-slow-scoring nil |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
424 "Inhibit slow scoring, e.g. scoring on headers or body. |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
425 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
426 If a regexp, scoring on headers or body is inhibited if the group |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
427 matches the regexp. If it is t, scoring on headers or body is |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
428 inhibited for all groups." |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
429 :group 'gnus-score-various |
92336
5f827896103e
Change defcustom :version from 23.0 to 23.1.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
430 :version "23.1" ;; No Gnus |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
431 :type '(choice (const :tag "All" nil) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
432 (const :tag "None" t) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
433 regexp)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
434 |
17493 | 435 |
436 | |
437 ;; Internal variables. | |
438 | |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
439 (defvar gnus-score-use-all-scores t |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
440 "If nil, only `gnus-score-find-score-files-function' is used.") |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
441 |
17493 | 442 (defvar gnus-adaptive-word-syntax-table |
443 (let ((table (copy-syntax-table (standard-syntax-table))) | |
444 (numbers '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9))) | |
445 (while numbers | |
446 (modify-syntax-entry (pop numbers) " " table)) | |
447 (modify-syntax-entry ?' "w" table) | |
448 table) | |
449 "Syntax table used when doing adaptive word scoring.") | |
450 | |
451 (defvar gnus-scores-exclude-files nil) | |
452 (defvar gnus-internal-global-score-files nil) | |
453 (defvar gnus-score-file-list nil) | |
454 | |
455 (defvar gnus-short-name-score-file-cache nil) | |
456 | |
457 (defvar gnus-score-help-winconf nil) | |
458 (defvar gnus-adaptive-score-alist gnus-default-adaptive-score-alist) | |
459 (defvar gnus-adaptive-word-score-alist gnus-default-adaptive-word-score-alist) | |
460 (defvar gnus-score-trace nil) | |
461 (defvar gnus-score-edit-buffer nil) | |
462 | |
463 (defvar gnus-score-alist nil | |
464 "Alist containing score information. | |
465 The keys can be symbols or strings. The following symbols are defined. | |
466 | |
467 touched: If this alist has been modified. | |
468 mark: Automatically mark articles below this. | |
469 expunge: Automatically expunge articles below this. | |
470 files: List of other score files to load when loading this one. | |
471 eval: Sexp to be evaluated when the score file is loaded. | |
472 | |
473 String entries have the form (HEADER (MATCH TYPE SCORE DATE) ...) | |
474 where HEADER is the header being scored, MATCH is the string we are | |
475 looking for, TYPE is a flag indicating whether it should use regexp or | |
476 substring matching, SCORE is the score to add and DATE is the date | |
477 of the last successful match.") | |
478 | |
479 (defvar gnus-score-cache nil) | |
480 (defvar gnus-scores-articles nil) | |
481 (defvar gnus-score-index nil) | |
482 | |
483 | |
484 (defconst gnus-header-index | |
485 ;; Name to index alist. | |
486 '(("number" 0 gnus-score-integer) | |
487 ("subject" 1 gnus-score-string) | |
488 ("from" 2 gnus-score-string) | |
489 ("date" 3 gnus-score-date) | |
490 ("message-id" 4 gnus-score-string) | |
491 ("references" 5 gnus-score-string) | |
492 ("chars" 6 gnus-score-integer) | |
493 ("lines" 7 gnus-score-integer) | |
494 ("xref" 8 gnus-score-string) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
495 ("extra" 9 gnus-score-string) |
17493 | 496 ("head" -1 gnus-score-body) |
497 ("body" -1 gnus-score-body) | |
498 ("all" -1 gnus-score-body) | |
499 ("followup" 2 gnus-score-followup) | |
500 ("thread" 5 gnus-score-thread))) | |
501 | |
502 ;;; Summary mode score maps. | |
503 | |
504 (gnus-define-keys (gnus-summary-score-map "V" gnus-summary-mode-map) | |
505 "s" gnus-summary-set-score | |
506 "S" gnus-summary-current-score | |
507 "c" gnus-score-change-score-file | |
508 "C" gnus-score-customize | |
509 "m" gnus-score-set-mark-below | |
510 "x" gnus-score-set-expunge-below | |
511 "R" gnus-summary-rescore | |
512 "e" gnus-score-edit-current-scores | |
513 "f" gnus-score-edit-file | |
514 "F" gnus-score-flush-cache | |
515 "t" gnus-score-find-trace | |
516 "w" gnus-score-find-favourite-words) | |
517 | |
518 ;; Summary score file commands | |
519 | |
520 ;; Much modification of the kill (ahem, score) code and lots of the | |
521 ;; functions are written by Per Abrahamsen <amanda@iesd.auc.dk>. | |
522 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
523 (defun gnus-summary-lower-score (&optional score symp) |
17493 | 524 "Make a score entry based on the current article. |
525 The user will be prompted for header to score on, match type, | |
526 permanence, and the string to be used. The numerical prefix will be | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
527 used as score. A symbolic prefix of `a' says to use the `all.SCORE' |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
528 file for the command instead of the current score file." |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
529 (interactive (gnus-interactive "P\ny")) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
530 (gnus-summary-increase-score (- (gnus-score-delta-default score)) symp)) |
17493 | 531 |
532 (defun gnus-score-kill-help-buffer () | |
533 (when (get-buffer "*Score Help*") | |
534 (kill-buffer "*Score Help*") | |
535 (when gnus-score-help-winconf | |
536 (set-window-configuration gnus-score-help-winconf)))) | |
537 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
538 (defun gnus-summary-increase-score (&optional score symp) |
17493 | 539 "Make a score entry based on the current article. |
540 The user will be prompted for header to score on, match type, | |
541 permanence, and the string to be used. The numerical prefix will be | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
542 used as score. A symbolic prefix of `a' says to use the `all.SCORE' |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
543 file for the command instead of the current score file." |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
544 (interactive (gnus-interactive "P\ny")) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
545 (let* ((nscore (gnus-score-delta-default score)) |
17493 | 546 (prefix (if (< nscore 0) ?L ?I)) |
547 (increase (> nscore 0)) | |
548 (char-to-header | |
549 '((?a "from" nil nil string) | |
550 (?s "subject" nil nil string) | |
551 (?b "body" "" nil body-string) | |
552 (?h "head" "" nil body-string) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
553 (?i "message-id" nil nil string) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
554 (?r "references" "message-id" nil string) |
17493 | 555 (?x "xref" nil nil string) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
556 (?e "extra" nil nil string) |
17493 | 557 (?l "lines" nil nil number) |
558 (?d "date" nil nil date) | |
559 (?f "followup" nil nil string) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
560 (?t "thread" "message-id" nil string))) |
17493 | 561 (char-to-type |
562 '((?s s "substring" string) | |
563 (?e e "exact string" string) | |
564 (?f f "fuzzy string" string) | |
565 (?r r "regexp string" string) | |
566 (?z s "substring" body-string) | |
567 (?p r "regexp string" body-string) | |
568 (?b before "before date" date) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
569 (?a after "after date" date) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
570 (?n at "this date" date) |
17493 | 571 (?< < "less than number" number) |
572 (?> > "greater than number" number) | |
573 (?= = "equal to number" number))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
574 (current-score-file gnus-current-score-file) |
17493 | 575 (char-to-perm |
576 (list (list ?t (current-time-string) "temporary") | |
577 '(?p perm "permanent") '(?i now "immediate"))) | |
578 (mimic gnus-score-mimic-keymap) | |
579 (hchar (and gnus-score-default-header | |
580 (aref (symbol-name gnus-score-default-header) 0))) | |
581 (tchar (and gnus-score-default-type | |
582 (aref (symbol-name gnus-score-default-type) 0))) | |
583 (pchar (and gnus-score-default-duration | |
584 (aref (symbol-name gnus-score-default-duration) 0))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
585 entry temporary type match extra) |
17493 | 586 |
587 (unwind-protect | |
588 (progn | |
589 | |
590 ;; First we read the header to score. | |
591 (while (not hchar) | |
592 (if mimic | |
593 (progn | |
594 (sit-for 1) | |
595 (message "%c-" prefix)) | |
596 (message "%s header (%s?): " (if increase "Increase" "Lower") | |
597 (mapconcat (lambda (s) (char-to-string (car s))) | |
598 char-to-header ""))) | |
599 (setq hchar (read-char)) | |
600 (when (or (= hchar ??) (= hchar ?\C-h)) | |
601 (setq hchar nil) | |
602 (gnus-score-insert-help "Match on header" char-to-header 1))) | |
603 | |
604 (gnus-score-kill-help-buffer) | |
605 (unless (setq entry (assq (downcase hchar) char-to-header)) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
606 (if mimic (error "%c %c" prefix hchar) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
607 (error "Invalid header type"))) |
17493 | 608 |
609 (when (/= (downcase hchar) hchar) | |
610 ;; This was a majuscule, so we end reading and set the defaults. | |
611 (if mimic (message "%c %c" prefix hchar) (message "")) | |
612 (setq tchar (or tchar ?s) | |
613 pchar (or pchar ?t))) | |
614 | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
615 (let ((legal-types |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
616 (delq nil |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
617 (mapcar (lambda (s) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
618 (if (eq (nth 4 entry) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
619 (nth 3 s)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
620 s nil)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
621 char-to-type)))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
622 ;; We continue reading - the type. |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
623 (while (not tchar) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
624 (if mimic |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
625 (progn |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
626 (sit-for 1) (message "%c %c-" prefix hchar)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
627 (message "%s header '%s' with match type (%s?): " |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
628 (if increase "Increase" "Lower") |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
629 (nth 1 entry) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
630 (mapconcat (lambda (s) (char-to-string (car s))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
631 legal-types ""))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
632 (setq tchar (read-char)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
633 (when (or (= tchar ??) (= tchar ?\C-h)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
634 (setq tchar nil) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
635 (gnus-score-insert-help "Match type" legal-types 2))) |
17493 | 636 |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
637 (gnus-score-kill-help-buffer) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
638 (unless (setq type (nth 1 (assq (downcase tchar) legal-types))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
639 (if mimic (error "%c %c" prefix hchar) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
640 (error "Invalid match type")))) |
17493 | 641 |
642 (when (/= (downcase tchar) tchar) | |
643 ;; It was a majuscule, so we end reading and use the default. | |
644 (if mimic (message "%c %c %c" prefix hchar tchar) | |
645 (message "")) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
646 (setq pchar (or pchar ?t))) |
17493 | 647 |
648 ;; We continue reading. | |
649 (while (not pchar) | |
650 (if mimic | |
651 (progn | |
652 (sit-for 1) (message "%c %c %c-" prefix hchar tchar)) | |
653 (message "%s permanence (%s?): " (if increase "Increase" "Lower") | |
654 (mapconcat (lambda (s) (char-to-string (car s))) | |
655 char-to-perm ""))) | |
656 (setq pchar (read-char)) | |
657 (when (or (= pchar ??) (= pchar ?\C-h)) | |
658 (setq pchar nil) | |
659 (gnus-score-insert-help "Match permanence" char-to-perm 2))) | |
660 | |
661 (gnus-score-kill-help-buffer) | |
53876
39dd3ea9e1d1
(gnus-summary-increase-score): Fix format string.
Andreas Schwab <schwab@suse.de>
parents:
52401
diff
changeset
|
662 (if mimic (message "%c %c %c %c" prefix hchar tchar pchar) |
17493 | 663 (message "")) |
664 (unless (setq temporary (cadr (assq pchar char-to-perm))) | |
665 ;; Deal with der(r)ided superannuated paradigms. | |
666 (when (and (eq (1+ prefix) 77) | |
667 (eq (+ hchar 12) 109) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
668 (eq (1- tchar) 113) |
17493 | 669 (eq (- pchar 4) 111)) |
670 (error "You rang?")) | |
671 (if mimic | |
672 (error "%c %c %c %c" prefix hchar tchar pchar) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
673 (error "Invalid match duration")))) |
17493 | 674 ;; Always kill the score help buffer. |
675 (gnus-score-kill-help-buffer)) | |
676 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
677 ;; If scoring an extra (non-standard overview) header, |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
678 ;; we must find out which header is in question. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
679 (setq extra |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
680 (and gnus-extra-headers |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
681 (equal (nth 1 entry) "extra") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
682 (intern ; need symbol |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
683 (gnus-completing-read-with-default |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
684 (symbol-name (car gnus-extra-headers)) ; default response |
65682
c16795de963a
2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents:
64754
diff
changeset
|
685 "Score extra header" ; prompt |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
686 (mapcar (lambda (x) ; completion list |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
687 (cons (symbol-name x) x)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
688 gnus-extra-headers) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
689 nil ; no completion limit |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
690 t)))) ; require match |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
691 ;; extra is now nil or a symbol. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
692 |
17493 | 693 ;; We have all the data, so we enter this score. |
694 (setq match (if (string= (nth 2 entry) "") "" | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
695 (gnus-summary-header (or (nth 2 entry) (nth 1 entry)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
696 nil extra))) |
17493 | 697 |
698 ;; Modify the match, perhaps. | |
699 (cond | |
700 ((equal (nth 1 entry) "xref") | |
701 (when (string-match "^Xref: *" match) | |
702 (setq match (substring match (match-end 0)))) | |
703 (when (string-match "^[^:]* +" match) | |
704 (setq match (substring match (match-end 0)))))) | |
705 | |
706 (when (memq type '(r R regexp Regexp)) | |
707 (setq match (regexp-quote match))) | |
708 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
709 ;; Change score file to the "all.SCORE" file. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
710 (when (eq symp 'a) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
711 (save-excursion |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
712 (set-buffer gnus-summary-buffer) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
713 (gnus-score-load-file |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
714 ;; This is a kludge; yes... |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
715 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
716 ((eq gnus-score-find-score-files-function |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
717 'gnus-score-find-hierarchical) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
718 (gnus-score-file-name "")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
719 ((eq gnus-score-find-score-files-function 'gnus-score-find-single) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
720 current-score-file) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
721 (t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
722 (gnus-score-file-name "all")))))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
723 |
17493 | 724 (gnus-summary-score-entry |
725 (nth 1 entry) ; Header | |
726 match ; Match | |
727 type ; Type | |
728 (if (eq score 's) nil score) ; Score | |
729 (if (eq temporary 'perm) ; Temp | |
730 nil | |
731 temporary) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
732 (not (nth 3 entry)) ; Prompt |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
733 nil ; not silent |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
734 extra) ; non-standard overview. |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
735 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
736 (when (eq symp 'a) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
737 ;; We change the score file back to the previous one. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
738 (save-excursion |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
739 (set-buffer gnus-summary-buffer) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
740 (gnus-score-load-file current-score-file))))) |
17493 | 741 |
742 (defun gnus-score-insert-help (string alist idx) | |
743 (setq gnus-score-help-winconf (current-window-configuration)) | |
744 (save-excursion | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
745 (set-buffer (gnus-get-buffer-create "*Score Help*")) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
746 (buffer-disable-undo) |
17493 | 747 (delete-windows-on (current-buffer)) |
748 (erase-buffer) | |
749 (insert string ":\n\n") | |
750 (let ((max -1) | |
751 (list alist) | |
752 (i 0) | |
753 n width pad format) | |
754 ;; find the longest string to display | |
755 (while list | |
756 (setq n (length (nth idx (car list)))) | |
757 (unless (> max n) | |
758 (setq max n)) | |
759 (setq list (cdr list))) | |
760 (setq max (+ max 4)) ; %c, `:', SPACE, a SPACE at end | |
761 (setq n (/ (1- (window-width)) max)) ; items per line | |
762 (setq width (/ (1- (window-width)) n)) ; width of each item | |
763 ;; insert `n' items, each in a field of width `width' | |
764 (while alist | |
765 (if (< i n) | |
766 () | |
767 (setq i 0) | |
768 (delete-char -1) ; the `\n' takes a char | |
769 (insert "\n")) | |
770 (setq pad (- width 3)) | |
771 (setq format (concat "%c: %-" (int-to-string pad) "s")) | |
772 (insert (format format (caar alist) (nth idx (car alist)))) | |
773 (setq alist (cdr alist)) | |
774 (setq i (1+ i)))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
775 (goto-char (point-min)) |
17493 | 776 ;; display ourselves in a small window at the bottom |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
777 (gnus-select-lowest-window) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
778 (if (< (/ (window-height) 2) window-min-height) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
779 (switch-to-buffer "*Score Help*") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
780 (split-window) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
781 (pop-to-buffer "*Score Help*")) |
17493 | 782 (let ((window-min-height 1)) |
783 (shrink-window-if-larger-than-buffer)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
784 (select-window (gnus-get-buffer-window gnus-summary-buffer t)))) |
17493 | 785 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
786 (defun gnus-summary-header (header &optional no-err extra) |
17493 | 787 ;; Return HEADER for current articles, or error. |
788 (let ((article (gnus-summary-article-number)) | |
789 headers) | |
790 (if article | |
791 (if (and (setq headers (gnus-summary-article-header article)) | |
792 (vectorp headers)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
793 (if extra ; `header' must be "extra" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
794 (or (cdr (assq extra (mail-header-extra headers))) "") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
795 (aref headers (nth 1 (assoc header gnus-header-index)))) |
17493 | 796 (if no-err |
797 nil | |
798 (error "Pseudo-articles can't be scored"))) | |
799 (if no-err | |
800 (error "No article on current line") | |
801 nil)))) | |
802 | |
803 (defun gnus-newsgroup-score-alist () | |
804 (or | |
805 (let ((param-file (gnus-group-find-parameter | |
806 gnus-newsgroup-name 'score-file))) | |
807 (when param-file | |
808 (gnus-score-load param-file))) | |
809 (gnus-score-load | |
810 (gnus-score-file-name gnus-newsgroup-name))) | |
811 gnus-score-alist) | |
812 | |
813 (defsubst gnus-score-get (symbol &optional alist) | |
814 ;; Get SYMBOL's definition in ALIST. | |
815 (cdr (assoc symbol | |
816 (or alist | |
817 gnus-score-alist | |
818 (gnus-newsgroup-score-alist))))) | |
819 | |
820 (defun gnus-summary-score-entry (header match type score date | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
821 &optional prompt silent extra) |
17493 | 822 "Enter score file entry. |
823 HEADER is the header being scored. | |
824 MATCH is the string we are looking for. | |
825 TYPE is the match type: substring, regexp, exact, fuzzy. | |
826 SCORE is the score to add. | |
827 DATE is the expire date, or nil for no expire, or 'now for immediate expire. | |
828 If optional argument `PROMPT' is non-nil, allow user to edit match. | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
829 If optional argument `SILENT' is nil, show effect of score entry. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
830 If optional argument `EXTRA' is non-nil, it's a non-standard overview header." |
17493 | 831 ;; Regexp is the default type. |
832 (when (eq type t) | |
833 (setq type 'r)) | |
834 ;; Simplify matches... | |
835 (cond ((or (eq type 'r) (eq type 's) (eq type nil)) | |
836 (setq match (if match (gnus-simplify-subject-re match) ""))) | |
837 ((eq type 'f) | |
838 (setq match (gnus-simplify-subject-fuzzy match)))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
839 (let ((score (gnus-score-delta-default score)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
840 (header (downcase header)) |
17493 | 841 new) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
842 (set-text-properties 0 (length header) nil header) |
17493 | 843 (when prompt |
844 (setq match (read-string | |
845 (format "Match %s on %s, %s: " | |
846 (cond ((eq date 'now) | |
847 "now") | |
848 ((stringp date) | |
849 "temp") | |
850 (t "permanent")) | |
851 header | |
852 (if (< score 0) "lower" "raise")) | |
853 (if (numberp match) | |
854 (int-to-string match) | |
855 match)))) | |
856 | |
857 ;; If this is an integer comparison, we transform from string to int. | |
35838
53eebdb81828
2001-02-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33319
diff
changeset
|
858 (if (eq (nth 2 (assoc header gnus-header-index)) 'gnus-score-integer) |
53eebdb81828
2001-02-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33319
diff
changeset
|
859 (if (stringp match) |
62907
88db2adda4b7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-339
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
860 (setq match (string-to-number match))) |
35838
53eebdb81828
2001-02-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33319
diff
changeset
|
861 (set-text-properties 0 (length match) nil match)) |
17493 | 862 |
863 (unless (eq date 'now) | |
864 ;; Add the score entry to the score file. | |
865 (when (= score gnus-score-interactive-default-score) | |
866 (setq score nil)) | |
867 (let ((old (gnus-score-get header)) | |
868 elem) | |
869 (setq new | |
870 (cond | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
871 (extra |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
872 (list match score |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
873 (and date (if (numberp date) date |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
874 (date-to-day date))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
875 type (symbol-name extra))) |
17493 | 876 (type |
877 (list match score | |
878 (and date (if (numberp date) date | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
879 (date-to-day date))) |
17493 | 880 type)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
881 (date (list match score (date-to-day date))) |
17493 | 882 (score (list match score)) |
883 (t (list match)))) | |
884 ;; We see whether we can collapse some score entries. | |
885 ;; This isn't quite correct, because there may be more elements | |
886 ;; later on with the same key that have matching elems... Hm. | |
887 (if (and old | |
888 (setq elem (assoc match old)) | |
889 (eq (nth 3 elem) (nth 3 new)) | |
890 (or (and (numberp (nth 2 elem)) (numberp (nth 2 new))) | |
891 (and (not (nth 2 elem)) (not (nth 2 new))))) | |
892 ;; Yup, we just add this new score to the old elem. | |
893 (setcar (cdr elem) (+ (or (nth 1 elem) | |
894 gnus-score-interactive-default-score) | |
895 (or (nth 1 new) | |
896 gnus-score-interactive-default-score))) | |
897 ;; Nope, we have to add a new elem. | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
898 (gnus-score-set header (if old (cons new old) (list new)) nil t)) |
17493 | 899 (gnus-score-set 'touched '(t)))) |
900 | |
901 ;; Score the current buffer. | |
902 (unless silent | |
903 (if (and (>= (nth 1 (assoc header gnus-header-index)) 0) | |
904 (eq (nth 2 (assoc header gnus-header-index)) | |
905 'gnus-score-string)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
906 (gnus-summary-score-effect header match type score extra) |
17493 | 907 (gnus-summary-rescore))) |
908 | |
909 ;; Return the new scoring rule. | |
910 new)) | |
911 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
912 (defun gnus-summary-score-effect (header match type score &optional extra) |
17493 | 913 "Simulate the effect of a score file entry. |
914 HEADER is the header being scored. | |
915 MATCH is the string we are looking for. | |
916 TYPE is the score type. | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
917 SCORE is the score to add. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
918 EXTRA is the possible non-standard header." |
17493 | 919 (interactive (list (completing-read "Header: " |
920 gnus-header-index | |
921 (lambda (x) (fboundp (nth 2 x))) | |
922 t) | |
923 (read-string "Match: ") | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
924 (if (y-or-n-p "Use regexp match? ") 'r 's) |
62907
88db2adda4b7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-339
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
925 (string-to-number (read-string "Score: ")))) |
17493 | 926 (save-excursion |
927 (unless (and (stringp match) (> (length match) 0)) | |
928 (error "No match")) | |
929 (goto-char (point-min)) | |
930 (let ((regexp (cond ((eq type 'f) | |
931 (gnus-simplify-subject-fuzzy match)) | |
932 ((eq type 'r) | |
933 match) | |
934 ((eq type 'e) | |
935 (concat "\\`" (regexp-quote match) "\\'")) | |
936 (t | |
937 (regexp-quote match))))) | |
938 (while (not (eobp)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
939 (let ((content (gnus-summary-header header 'noerr extra)) |
17493 | 940 (case-fold-search t)) |
941 (and content | |
942 (when (if (eq type 'f) | |
943 (string-equal (gnus-simplify-subject-fuzzy content) | |
944 regexp) | |
945 (string-match regexp content)) | |
946 (gnus-summary-raise-score score)))) | |
947 (beginning-of-line 2)))) | |
948 (gnus-set-mode-line 'summary)) | |
949 | |
950 (defun gnus-summary-score-crossposting (score date) | |
951 ;; Enter score file entry for current crossposting. | |
952 ;; SCORE is the score to add. | |
953 ;; DATE is the expire date. | |
954 (let ((xref (gnus-summary-header "xref")) | |
955 (start 0) | |
956 group) | |
957 (unless xref | |
958 (error "This article is not crossposted")) | |
959 (while (string-match " \\([^ \t]+\\):" xref start) | |
960 (setq start (match-end 0)) | |
961 (when (not (string= | |
962 (setq group | |
963 (substring xref (match-beginning 1) (match-end 1))) | |
964 gnus-newsgroup-name)) | |
965 (gnus-summary-score-entry | |
966 "xref" (concat " " group ":") nil score date t))))) | |
967 | |
968 | |
969 ;;; | |
970 ;;; Gnus Score Files | |
971 ;;; | |
972 | |
973 ;; All score code written by Per Abrahamsen <abraham@iesd.auc.dk>. | |
974 | |
975 (defun gnus-score-set-mark-below (score) | |
976 "Automatically mark articles with score below SCORE as read." | |
977 (interactive | |
978 (list (or (and current-prefix-arg (prefix-numeric-value current-prefix-arg)) | |
62907
88db2adda4b7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-339
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
979 (string-to-number (read-string "Mark below: "))))) |
17493 | 980 (setq score (or score gnus-summary-default-score 0)) |
981 (gnus-score-set 'mark (list score)) | |
982 (gnus-score-set 'touched '(t)) | |
983 (setq gnus-summary-mark-below score) | |
984 (gnus-score-update-lines)) | |
985 | |
986 (defun gnus-score-update-lines () | |
987 "Update all lines in the summary buffer." | |
988 (save-excursion | |
989 (goto-char (point-min)) | |
990 (while (not (eobp)) | |
991 (gnus-summary-update-line) | |
992 (forward-line 1)))) | |
993 | |
994 (defun gnus-score-update-all-lines () | |
995 "Update all lines in the summary buffer, even the hidden ones." | |
996 (save-excursion | |
997 (goto-char (point-min)) | |
998 (let (hidden) | |
999 (while (not (eobp)) | |
1000 (when (gnus-summary-show-thread) | |
1001 (push (point) hidden)) | |
1002 (gnus-summary-update-line) | |
1003 (forward-line 1)) | |
1004 ;; Re-hide the hidden threads. | |
1005 (while hidden | |
1006 (goto-char (pop hidden)) | |
1007 (gnus-summary-hide-thread))))) | |
1008 | |
1009 (defun gnus-score-set-expunge-below (score) | |
1010 "Automatically expunge articles with score below SCORE." | |
1011 (interactive | |
1012 (list (or (and current-prefix-arg (prefix-numeric-value current-prefix-arg)) | |
62907
88db2adda4b7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-339
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
1013 (string-to-number (read-string "Set expunge below: "))))) |
17493 | 1014 (setq score (or score gnus-summary-default-score 0)) |
1015 (gnus-score-set 'expunge (list score)) | |
1016 (gnus-score-set 'touched '(t))) | |
1017 | |
1018 (defun gnus-score-followup-article (&optional score) | |
1019 "Add SCORE to all followups to the article in the current buffer." | |
1020 (interactive "P") | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1021 (setq score (gnus-score-delta-default score)) |
17493 | 1022 (when (gnus-buffer-live-p gnus-summary-buffer) |
1023 (save-excursion | |
1024 (save-restriction | |
1025 (message-narrow-to-headers) | |
1026 (let ((id (mail-fetch-field "message-id"))) | |
1027 (when id | |
1028 (set-buffer gnus-summary-buffer) | |
1029 (gnus-summary-score-entry | |
1030 "references" (concat id "[ \t]*$") 'r | |
1031 score (current-time-string) nil t))))))) | |
1032 | |
1033 (defun gnus-score-followup-thread (&optional score) | |
1034 "Add SCORE to all later articles in the thread the current buffer is part of." | |
1035 (interactive "P") | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1036 (setq score (gnus-score-delta-default score)) |
17493 | 1037 (when (gnus-buffer-live-p gnus-summary-buffer) |
1038 (save-excursion | |
1039 (save-restriction | |
1040 (goto-char (point-min)) | |
1041 (let ((id (mail-fetch-field "message-id"))) | |
1042 (when id | |
1043 (set-buffer gnus-summary-buffer) | |
1044 (gnus-summary-score-entry | |
1045 "references" id 's | |
1046 score (current-time-string)))))))) | |
1047 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1048 (defun gnus-score-set (symbol value &optional alist warn) |
17493 | 1049 ;; Set SYMBOL to VALUE in ALIST. |
1050 (let* ((alist | |
1051 (or alist | |
1052 gnus-score-alist | |
1053 (gnus-newsgroup-score-alist))) | |
1054 (entry (assoc symbol alist))) | |
1055 (cond ((gnus-score-get 'read-only alist) | |
1056 ;; This is a read-only score file, so we do nothing. | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1057 (when warn |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1058 (gnus-message 4 "Note: read-only score file; entry discarded"))) |
17493 | 1059 (entry |
1060 (setcdr entry value)) | |
1061 ((null alist) | |
1062 (error "Empty alist")) | |
1063 (t | |
1064 (setcdr alist | |
1065 (cons (cons symbol value) (cdr alist))))))) | |
1066 | |
1067 (defun gnus-summary-raise-score (n) | |
1068 "Raise the score of the current article by N." | |
1069 (interactive "p") | |
1070 (gnus-summary-set-score (+ (gnus-summary-article-score) | |
1071 (or n gnus-score-interactive-default-score )))) | |
1072 | |
1073 (defun gnus-summary-set-score (n) | |
1074 "Set the score of the current article to N." | |
1075 (interactive "p") | |
1076 (save-excursion | |
1077 (gnus-summary-show-thread) | |
1078 (let ((buffer-read-only nil)) | |
1079 ;; Set score. | |
1080 (gnus-summary-update-mark | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1081 (if (= n (or gnus-summary-default-score 0)) ? ;Whitespace |
17493 | 1082 (if (< n (or gnus-summary-default-score 0)) |
1083 gnus-score-below-mark gnus-score-over-mark)) | |
1084 'score)) | |
1085 (let* ((article (gnus-summary-article-number)) | |
1086 (score (assq article gnus-newsgroup-scored))) | |
1087 (if score (setcdr score n) | |
1088 (push (cons article n) gnus-newsgroup-scored))) | |
1089 (gnus-summary-update-line))) | |
1090 | |
1091 (defun gnus-summary-current-score () | |
1092 "Return the score of the current article." | |
1093 (interactive) | |
1094 (gnus-message 1 "%s" (gnus-summary-article-score))) | |
1095 | |
1096 (defun gnus-score-change-score-file (file) | |
1097 "Change current score alist." | |
1098 (interactive | |
1099 (list (read-file-name "Change to score file: " gnus-kill-files-directory))) | |
1100 (gnus-score-load-file file) | |
1101 (gnus-set-mode-line 'summary)) | |
1102 | |
1103 (defvar gnus-score-edit-exit-function) | |
1104 (defun gnus-score-edit-current-scores (file) | |
1105 "Edit the current score alist." | |
1106 (interactive (list gnus-current-score-file)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1107 (if (not gnus-current-score-file) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1108 (error "No current score file") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1109 (let ((winconf (current-window-configuration))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1110 (when (buffer-name gnus-summary-buffer) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1111 (gnus-score-save)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1112 (gnus-make-directory (file-name-directory file)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1113 (setq gnus-score-edit-buffer (find-file-noselect file)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1114 (gnus-configure-windows 'edit-score) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1115 (gnus-score-mode) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1116 (setq gnus-score-edit-exit-function 'gnus-score-edit-done) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1117 (make-local-variable 'gnus-prev-winconf) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1118 (setq gnus-prev-winconf winconf)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1119 (gnus-message |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1120 4 (substitute-command-keys |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1121 "\\<gnus-score-mode-map>\\[gnus-score-edit-exit] to save edits")))) |
17493 | 1122 |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1123 (defun gnus-score-edit-all-score () |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1124 "Edit the all.SCORE file." |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1125 (interactive) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1126 (find-file (gnus-score-file-name "all")) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1127 (gnus-score-mode) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1128 (setq gnus-score-edit-exit-function 'gnus-score-edit-done) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1129 (gnus-message |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1130 4 (substitute-command-keys |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1131 "\\<gnus-score-mode-map>\\[gnus-score-edit-exit] to save edits"))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1132 |
17493 | 1133 (defun gnus-score-edit-file (file) |
1134 "Edit a score file." | |
1135 (interactive | |
1136 (list (read-file-name "Edit score file: " gnus-kill-files-directory))) | |
1137 (gnus-make-directory (file-name-directory file)) | |
1138 (when (buffer-name gnus-summary-buffer) | |
1139 (gnus-score-save)) | |
1140 (let ((winconf (current-window-configuration))) | |
1141 (setq gnus-score-edit-buffer (find-file-noselect file)) | |
1142 (gnus-configure-windows 'edit-score) | |
1143 (gnus-score-mode) | |
1144 (setq gnus-score-edit-exit-function 'gnus-score-edit-done) | |
1145 (make-local-variable 'gnus-prev-winconf) | |
1146 (setq gnus-prev-winconf winconf)) | |
1147 (gnus-message | |
1148 4 (substitute-command-keys | |
1149 "\\<gnus-score-mode-map>\\[gnus-score-edit-exit] to save edits"))) | |
1150 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1151 (defun gnus-score-edit-file-at-point (&optional format) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1152 "Edit score file at point in Score Trace buffers. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1153 If FORMAT, also format the current score file." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1154 (let* ((rule (save-excursion |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1155 (beginning-of-line) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1156 (read (current-buffer)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1157 (sep "[ \n\r\t]*") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1158 ;; Must be synced with `gnus-score-find-trace': |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1159 (reg " -> +") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1160 (file (save-excursion |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1161 (end-of-line) |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1162 (if (and (re-search-backward reg (point-at-bol) t) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1163 (re-search-forward reg (point-at-eol) t)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1164 (buffer-substring (point) (point-at-eol)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1165 nil)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1166 (if (or (not file) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1167 (string-match "\\<\\(non-file rule\\|A file\\)\\>" file) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1168 ;; (see `gnus-score-find-trace' and `gnus-score-advanced') |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1169 (string= "" file)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1170 (gnus-error 3 "Can't find a score file in current line.") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1171 (gnus-score-edit-file file) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1172 (when format |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1173 (gnus-score-pretty-print)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1174 (when (consp rule) ;; the rule exists |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1175 (setq rule (mapconcat #'(lambda (obj) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1176 (regexp-quote (format "%S" obj))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1177 rule |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1178 sep)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1179 (goto-char (point-min)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1180 (re-search-forward rule nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1181 ;; make it easy to use `kill-sexp': |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1182 (goto-char (1- (match-beginning 0))))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1183 |
17493 | 1184 (defun gnus-score-load-file (file) |
1185 ;; Load score file FILE. Returns a list a retrieved score-alists. | |
1186 (let* ((file (expand-file-name | |
1187 (or (and (string-match | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1188 (concat "^" (regexp-quote |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1189 (expand-file-name |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1190 gnus-kill-files-directory))) |
17493 | 1191 (expand-file-name file)) |
1192 file) | |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1193 (expand-file-name file gnus-kill-files-directory)))) |
17493 | 1194 (cached (assoc file gnus-score-cache)) |
1195 (global (member file gnus-internal-global-score-files)) | |
1196 lists alist) | |
1197 (if cached | |
1198 ;; The score file was already loaded. | |
1199 (setq alist (cdr cached)) | |
1200 ;; We load the score file. | |
1201 (setq gnus-score-alist nil) | |
1202 (setq alist (gnus-score-load-score-alist file)) | |
1203 ;; We add '(touched) to the alist to signify that it hasn't been | |
1204 ;; touched (yet). | |
1205 (unless (assq 'touched alist) | |
1206 (push (list 'touched nil) alist)) | |
1207 ;; If it is a global score file, we make it read-only. | |
1208 (and global | |
1209 (not (assq 'read-only alist)) | |
1210 (push (list 'read-only t) alist)) | |
1211 (push (cons file alist) gnus-score-cache)) | |
1212 (let ((a alist) | |
1213 found) | |
1214 (while a | |
1215 ;; Downcase all header names. | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1216 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1217 ((stringp (caar a)) |
17493 | 1218 (setcar (car a) (downcase (caar a))) |
1219 (setq found t)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1220 ;; Advanced scoring. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1221 ((consp (caar a)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1222 (setq found t))) |
17493 | 1223 (pop a)) |
1224 ;; If there are actual scores in the alist, we add it to the | |
1225 ;; return value of this function. | |
1226 (when found | |
1227 (setq lists (list alist)))) | |
1228 ;; Treat the other possible atoms in the score alist. | |
1229 (let ((mark (car (gnus-score-get 'mark alist))) | |
1230 (expunge (car (gnus-score-get 'expunge alist))) | |
1231 (mark-and-expunge (car (gnus-score-get 'mark-and-expunge alist))) | |
1232 (files (gnus-score-get 'files alist)) | |
1233 (exclude-files (gnus-score-get 'exclude-files alist)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1234 (orphan (car (gnus-score-get 'orphan alist))) |
17493 | 1235 (adapt (gnus-score-get 'adapt alist)) |
1236 (thread-mark-and-expunge | |
1237 (car (gnus-score-get 'thread-mark-and-expunge alist))) | |
1238 (adapt-file (car (gnus-score-get 'adapt-file alist))) | |
1239 (local (gnus-score-get 'local alist)) | |
1240 (decay (car (gnus-score-get 'decay alist))) | |
1241 (eval (car (gnus-score-get 'eval alist)))) | |
1242 ;; Perform possible decays. | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1243 (when (and (if (stringp gnus-decay-scores) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1244 (string-match gnus-decay-scores file) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1245 gnus-decay-scores) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1246 (or cached (file-exists-p file)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1247 (or (not decay) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1248 (gnus-decay-scores alist decay))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1249 (gnus-score-set 'touched '(t) alist) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1250 (gnus-score-set 'decay (list (time-to-days (current-time))) alist)) |
17493 | 1251 ;; We do not respect eval and files atoms from global score |
1252 ;; files. | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1253 (when (and files (not global)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1254 (setq lists (apply 'append lists |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1255 (mapcar 'gnus-score-load-file |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1256 (if adapt-file (cons adapt-file files) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1257 files))))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1258 (when (and eval (not global)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1259 (eval eval)) |
17493 | 1260 ;; We then expand any exclude-file directives. |
1261 (setq gnus-scores-exclude-files | |
1262 (nconc | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1263 (apply |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1264 'nconc |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1265 (mapcar |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1266 (lambda (sfile) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1267 (list |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1268 (expand-file-name sfile (file-name-directory file)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1269 (expand-file-name sfile gnus-kill-files-directory))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1270 exclude-files)) |
17493 | 1271 gnus-scores-exclude-files)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1272 (when local |
17493 | 1273 (save-excursion |
1274 (set-buffer gnus-summary-buffer) | |
1275 (while local | |
1276 (and (consp (car local)) | |
1277 (symbolp (caar local)) | |
1278 (progn | |
1279 (make-local-variable (caar local)) | |
1280 (set (caar local) (nth 1 (car local))))) | |
1281 (setq local (cdr local))))) | |
1282 (when orphan | |
1283 (setq gnus-orphan-score orphan)) | |
1284 (setq gnus-adaptive-score-alist | |
1285 (cond ((equal adapt '(t)) | |
1286 (setq gnus-newsgroup-adaptive t) | |
1287 gnus-default-adaptive-score-alist) | |
1288 ((equal adapt '(ignore)) | |
1289 (setq gnus-newsgroup-adaptive nil)) | |
1290 ((consp adapt) | |
1291 (setq gnus-newsgroup-adaptive t) | |
1292 adapt) | |
1293 (t | |
1294 gnus-default-adaptive-score-alist))) | |
1295 (setq gnus-thread-expunge-below | |
1296 (or thread-mark-and-expunge gnus-thread-expunge-below)) | |
1297 (setq gnus-summary-mark-below | |
1298 (or mark mark-and-expunge gnus-summary-mark-below)) | |
1299 (setq gnus-summary-expunge-below | |
1300 (or expunge mark-and-expunge gnus-summary-expunge-below)) | |
1301 (setq gnus-newsgroup-adaptive-score-file | |
1302 (or adapt-file gnus-newsgroup-adaptive-score-file))) | |
1303 (setq gnus-current-score-file file) | |
1304 (setq gnus-score-alist alist) | |
1305 lists)) | |
1306 | |
1307 (defun gnus-score-load (file) | |
1308 ;; Load score FILE. | |
1309 (let ((cache (assoc file gnus-score-cache))) | |
1310 (if cache | |
1311 (setq gnus-score-alist (cdr cache)) | |
1312 (setq gnus-score-alist nil) | |
1313 (gnus-score-load-score-alist file) | |
1314 (unless gnus-score-alist | |
1315 (setq gnus-score-alist (copy-alist '((touched nil))))) | |
1316 (push (cons file gnus-score-alist) gnus-score-cache)))) | |
1317 | |
1318 (defun gnus-score-remove-from-cache (file) | |
1319 (setq gnus-score-cache | |
1320 (delq (assoc file gnus-score-cache) gnus-score-cache))) | |
1321 | |
1322 (defun gnus-score-load-score-alist (file) | |
1323 "Read score FILE." | |
1324 (let (alist) | |
1325 (if (not (file-readable-p file)) | |
1326 ;; Couldn't read file. | |
1327 (setq gnus-score-alist nil) | |
1328 ;; Read file. | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1329 (with-temp-buffer |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1330 (let ((coding-system-for-read score-mode-coding-system)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1331 (insert-file-contents file)) |
17493 | 1332 (goto-char (point-min)) |
1333 ;; Only do the loading if the score file isn't empty. | |
1334 (when (save-excursion (re-search-forward "[()0-9a-zA-Z]" nil t)) | |
1335 (setq alist | |
1336 (condition-case () | |
1337 (read (current-buffer)) | |
1338 (error | |
1339 (gnus-error 3.2 "Problem with score file %s" file)))))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1340 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1341 ((and alist |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1342 (atom alist)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1343 ;; Bogus score file. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1344 (error "Invalid syntax with score file %s" file)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1345 ((eq (car alist) 'setq) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1346 ;; This is an old-style score file. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1347 (setq gnus-score-alist (gnus-score-transform-old-to-new alist))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1348 (t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1349 (setq gnus-score-alist alist))) |
17493 | 1350 ;; Check the syntax of the score file. |
1351 (setq gnus-score-alist | |
1352 (gnus-score-check-syntax gnus-score-alist file))))) | |
1353 | |
1354 (defun gnus-score-check-syntax (alist file) | |
1355 "Check the syntax of the score ALIST." | |
1356 (cond | |
1357 ((null alist) | |
1358 nil) | |
1359 ((not (consp alist)) | |
1360 (gnus-message 1 "Score file is not a list: %s" file) | |
1361 (ding) | |
1362 nil) | |
1363 (t | |
1364 (let ((a alist) | |
1365 sr err s type) | |
1366 (while (and a (not err)) | |
1367 (setq | |
1368 err | |
1369 (cond | |
1370 ((not (listp (car a))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1371 (format "Invalid score element %s in %s" (car a) file)) |
17493 | 1372 ((stringp (caar a)) |
1373 (cond | |
1374 ((not (listp (setq sr (cdar a)))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1375 (format "Invalid header match %s in %s" (nth 1 (car a)) file)) |
17493 | 1376 (t |
1377 (setq type (caar a)) | |
1378 (while (and sr (not err)) | |
1379 (setq s (pop sr)) | |
1380 (setq | |
1381 err | |
1382 (cond | |
1383 ((if (member (downcase type) '("lines" "chars")) | |
1384 (not (numberp (car s))) | |
1385 (not (stringp (car s)))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1386 (format "Invalid match %s in %s" (car s) file)) |
17493 | 1387 ((and (cadr s) (not (integerp (cadr s)))) |
1388 (format "Non-integer score %s in %s" (cadr s) file)) | |
1389 ((and (caddr s) (not (integerp (caddr s)))) | |
1390 (format "Non-integer date %s in %s" (caddr s) file)) | |
1391 ((and (cadddr s) (not (symbolp (cadddr s)))) | |
1392 (format "Non-symbol match type %s in %s" (cadddr s) file))))) | |
1393 err))))) | |
1394 (setq a (cdr a))) | |
1395 (if err | |
1396 (progn | |
1397 (ding) | |
1398 (gnus-message 3 err) | |
1399 (sit-for 2) | |
1400 nil) | |
1401 alist))))) | |
1402 | |
1403 (defun gnus-score-transform-old-to-new (alist) | |
1404 (let* ((alist (nth 2 alist)) | |
1405 out entry) | |
1406 (when (eq (car alist) 'quote) | |
1407 (setq alist (nth 1 alist))) | |
1408 (while alist | |
1409 (setq entry (car alist)) | |
1410 (if (stringp (car entry)) | |
1411 (let ((scor (cdr entry))) | |
1412 (push entry out) | |
1413 (while scor | |
1414 (setcar scor | |
1415 (list (caar scor) (nth 2 (car scor)) | |
1416 (and (nth 3 (car scor)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1417 (date-to-day (nth 3 (car scor)))) |
17493 | 1418 (if (nth 1 (car scor)) 'r 's))) |
1419 (setq scor (cdr scor)))) | |
1420 (push (if (not (listp (cdr entry))) | |
1421 (list (car entry) (cdr entry)) | |
1422 entry) | |
1423 out)) | |
1424 (setq alist (cdr alist))) | |
1425 (cons (list 'touched t) (nreverse out)))) | |
1426 | |
1427 (defun gnus-score-save () | |
1428 ;; Save all score information. | |
1429 (let ((cache gnus-score-cache) | |
1430 entry score file) | |
1431 (save-excursion | |
1432 (setq gnus-score-alist nil) | |
1433 (nnheader-set-temp-buffer " *Gnus Scores*") | |
1434 (while cache | |
1435 (current-buffer) | |
1436 (setq entry (pop cache) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1437 file (nnheader-translate-file-chars (car entry) t) |
17493 | 1438 score (cdr entry)) |
1439 (if (or (not (equal (gnus-score-get 'touched score) '(t))) | |
1440 (gnus-score-get 'read-only score) | |
1441 (and (file-exists-p file) | |
1442 (not (file-writable-p file)))) | |
1443 () | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1444 (setq score (setcdr entry (gnus-delete-alist 'touched score))) |
17493 | 1445 (erase-buffer) |
1446 (let (emacs-lisp-mode-hook) | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1447 (if (and (not gnus-adaptive-pretty-print) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1448 (string-match |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1449 (concat (regexp-quote gnus-adaptive-file-suffix) "$") |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1450 file)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1451 ;; This is an adaptive score file, so we do not run it through |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1452 ;; `pp' unless requested. These files can get huge, and are |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1453 ;; not meant to be edited by human hands. |
17493 | 1454 (gnus-prin1 score) |
1455 ;; This is a normal score file, so we print it very | |
1456 ;; prettily. | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1457 (let ((lisp-mode-syntax-table score-mode-syntax-table)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1458 (gnus-pp score)))) |
17493 | 1459 (gnus-make-directory (file-name-directory file)) |
1460 ;; If the score file is empty, we delete it. | |
1461 (if (zerop (buffer-size)) | |
1462 (delete-file file) | |
1463 ;; There are scores, so we write the file. | |
1464 (when (file-writable-p file) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1465 (let ((coding-system-for-write score-mode-coding-system)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1466 (gnus-write-buffer file)) |
17493 | 1467 (when gnus-score-after-write-file-function |
1468 (funcall gnus-score-after-write-file-function file))))) | |
1469 (and gnus-score-uncacheable-files | |
1470 (string-match gnus-score-uncacheable-files file) | |
1471 (gnus-score-remove-from-cache file))) | |
1472 (kill-buffer (current-buffer))))) | |
1473 | |
1474 (defun gnus-score-load-files (score-files) | |
1475 "Load all score files in SCORE-FILES." | |
1476 ;; Load the score files. | |
1477 (let (scores) | |
1478 (while score-files | |
1479 (if (stringp (car score-files)) | |
1480 ;; It is a string, which means that it's a score file name, | |
1481 ;; so we load the score file and add the score alist to | |
1482 ;; the list of alists. | |
1483 (setq scores (nconc (gnus-score-load-file (car score-files)) scores)) | |
1484 ;; It is an alist, so we just add it to the list directly. | |
1485 (setq scores (nconc (car score-files) scores))) | |
1486 (setq score-files (cdr score-files))) | |
1487 ;; Prune the score files that are to be excluded, if any. | |
1488 (when gnus-scores-exclude-files | |
1489 (let ((s scores) | |
1490 c) | |
1491 (while s | |
1492 (and (setq c (rassq (car s) gnus-score-cache)) | |
1493 (member (car c) gnus-scores-exclude-files) | |
1494 (setq scores (delq (car s) scores))) | |
1495 (setq s (cdr s))))) | |
1496 scores)) | |
1497 | |
1498 (defun gnus-score-headers (score-files &optional trace) | |
1499 ;; Score `gnus-newsgroup-headers'. | |
1500 (let (scores news) | |
1501 ;; PLM: probably this is not the best place to clear orphan-score | |
1502 (setq gnus-orphan-score nil | |
1503 gnus-scores-articles nil | |
1504 gnus-scores-exclude-files nil | |
1505 scores (gnus-score-load-files score-files)) | |
1506 (setq news scores) | |
1507 ;; Do the scoring. | |
1508 (while news | |
1509 (setq scores news | |
1510 news nil) | |
1511 (when (and gnus-summary-default-score | |
1512 scores) | |
1513 (let* ((entries gnus-header-index) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1514 (now (date-to-day (current-time-string))) |
17493 | 1515 (expire (and gnus-score-expiry-days |
1516 (- now gnus-score-expiry-days))) | |
1517 (headers gnus-newsgroup-headers) | |
1518 (current-score-file gnus-current-score-file) | |
1519 entry header new) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1520 (gnus-message 7 "Scoring...") |
17493 | 1521 ;; Create articles, an alist of the form `(HEADER . SCORE)'. |
1522 (while (setq header (pop headers)) | |
1523 ;; WARNING: The assq makes the function O(N*S) while it could | |
1524 ;; be written as O(N+S), where N is (length gnus-newsgroup-headers) | |
1525 ;; and S is (length gnus-newsgroup-scored). | |
1526 (unless (assq (mail-header-number header) gnus-newsgroup-scored) | |
1527 (setq gnus-scores-articles ;Total of 2 * N cons-cells used. | |
1528 (cons (cons header (or gnus-summary-default-score 0)) | |
1529 gnus-scores-articles)))) | |
1530 | |
1531 (save-excursion | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1532 (set-buffer (gnus-get-buffer-create "*Headers*")) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1533 (buffer-disable-undo) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1534 (when (gnus-buffer-live-p gnus-summary-buffer) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
1535 (message-clone-locals gnus-summary-buffer)) |
17493 | 1536 |
1537 ;; Set the global variant of this variable. | |
1538 (setq gnus-current-score-file current-score-file) | |
1539 ;; score orphans | |
1540 (when gnus-orphan-score | |
1541 (setq gnus-score-index | |
1542 (nth 1 (assoc "references" gnus-header-index))) | |
1543 (gnus-score-orphans gnus-orphan-score)) | |
1544 ;; Run each header through the score process. | |
1545 (while entries | |
1546 (setq entry (pop entries) | |
1547 header (nth 0 entry) | |
1548 gnus-score-index (nth 1 (assoc header gnus-header-index))) | |
1549 (when (< 0 (apply 'max (mapcar | |
1550 (lambda (score) | |
1551 (length (gnus-score-get header score))) | |
1552 scores))) | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1553 (when (if (and gnus-inhibit-slow-scoring |
93386 | 1554 (or (eq gnus-inhibit-slow-scoring t) |
1555 (and (stringp gnus-inhibit-slow-scoring) | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1556 ;; Always true here? |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1557 ;; (stringp gnus-newsgroup-name) |
93386 | 1558 (string-match |
1559 gnus-inhibit-slow-scoring | |
1560 gnus-newsgroup-name))) | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1561 (> 0 (nth 1 (assoc header gnus-header-index)))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1562 (progn |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1563 (gnus-message |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1564 7 "Scoring on headers or body skipped.") |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1565 nil) |
93386 | 1566 ;; Call the scoring function for this type of "header". |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1567 (setq new (funcall (nth 2 entry) scores header |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1568 now expire trace))) |
17493 | 1569 (push new news)))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1570 (when (gnus-buffer-live-p gnus-summary-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1571 (let ((scored gnus-newsgroup-scored)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1572 (with-current-buffer gnus-summary-buffer |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1573 (setq gnus-newsgroup-scored scored)))) |
17493 | 1574 ;; Remove the buffer. |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1575 (gnus-kill-buffer (current-buffer))) |
17493 | 1576 |
1577 ;; Add articles to `gnus-newsgroup-scored'. | |
1578 (while gnus-scores-articles | |
1579 (when (or (/= gnus-summary-default-score | |
1580 (cdar gnus-scores-articles)) | |
1581 gnus-save-score) | |
1582 (push (cons (mail-header-number (caar gnus-scores-articles)) | |
1583 (cdar gnus-scores-articles)) | |
1584 gnus-newsgroup-scored)) | |
1585 (setq gnus-scores-articles (cdr gnus-scores-articles))) | |
1586 | |
1587 (let (score) | |
1588 (while (setq score (pop scores)) | |
1589 (while score | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1590 (when (consp (caar score)) |
17493 | 1591 (gnus-score-advanced (car score) trace)) |
1592 (pop score)))) | |
1593 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1594 (gnus-message 7 "Scoring...done")))))) |
17493 | 1595 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1596 (defun gnus-score-lower-thread (thread score-adjust) |
35838
53eebdb81828
2001-02-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33319
diff
changeset
|
1597 "Lower the score on THREAD with SCORE-ADJUST. |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1598 THREAD is expected to contain a list of the form `(PARENT [CHILD1 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1599 CHILD2 ...])' where PARENT is a header array and each CHILD is a list |
50850
7d09b72f86c0
(gnus-score-lower-thread): Don't quote nil and t in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
41494
diff
changeset
|
1600 of the same form as THREAD. The empty list nil is valid. For each |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1601 article in the tree, the score of the corresponding entry in |
41059
70987a4f43c8
Fixed some doc strings to properly quote symbols.
Sam Steingold <sds@gnu.org>
parents:
35978
diff
changeset
|
1602 `gnus-newsgroup-scored' is adjusted by SCORE-ADJUST." |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1603 (while thread |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1604 (let ((head (car thread))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1605 (if (listp head) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1606 ;; handle a child and its descendants |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1607 (gnus-score-lower-thread head score-adjust) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1608 ;; handle the parent |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1609 (let* ((article (mail-header-number head)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1610 (score (assq article gnus-newsgroup-scored))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1611 (if score (setcdr score (+ (cdr score) score-adjust)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1612 (push (cons article score-adjust) gnus-newsgroup-scored))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1613 (setq thread (cdr thread)))) |
17493 | 1614 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1615 (defun gnus-score-orphans (score) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1616 "Score orphans. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1617 A root is an article with no references. An orphan is an article |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1618 which has references, but is not connected via its references to a |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1619 root article. This function finds all the orphans, and adjusts their |
41059
70987a4f43c8
Fixed some doc strings to properly quote symbols.
Sam Steingold <sds@gnu.org>
parents:
35978
diff
changeset
|
1620 score in `gnus-newsgroup-scored' by SCORE." |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1621 ;; gnus-make-threads produces a list, where each entry is a "thread" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1622 ;; as described in the gnus-score-lower-thread docs. This function |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1623 ;; will be called again (after limiting has been done) if the display |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1624 ;; is threaded. It would be nice to somehow save this info and use |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1625 ;; it later. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1626 (dolist (thread (gnus-make-threads)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1627 (let ((id (aref (car thread) gnus-score-index))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1628 ;; If the parent of the thread is not a root, lower the score of |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1629 ;; it and its descendants. Note that some roots seem to satisfy |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1630 ;; (eq id nil) and some (eq id ""); not sure why. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1631 (when (and id |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1632 (not (string= id ""))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1633 (gnus-score-lower-thread thread score))))) |
17493 | 1634 |
1635 (defun gnus-score-integer (scores header now expire &optional trace) | |
1636 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index))) | |
1637 entries alist) | |
1638 ;; Find matches. | |
1639 (while scores | |
1640 (setq alist (car scores) | |
1641 scores (cdr scores) | |
1642 entries (assoc header alist)) | |
1643 (while (cdr entries) ;First entry is the header index. | |
1644 (let* ((rest (cdr entries)) | |
1645 (kill (car rest)) | |
1646 (match (nth 0 kill)) | |
1647 (type (or (nth 3 kill) '>)) | |
1648 (score (or (nth 1 kill) gnus-score-interactive-default-score)) | |
1649 (date (nth 2 kill)) | |
1650 (found nil) | |
1651 (match-func (if (or (eq type '>) (eq type '<) (eq type '<=) | |
1652 (eq type '>=) (eq type '=)) | |
1653 type | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1654 (error "Invalid match type: %s" type))) |
17493 | 1655 (articles gnus-scores-articles)) |
1656 ;; Instead of doing all the clever stuff that | |
1657 ;; `gnus-score-string' does to minimize searches and stuff, | |
1658 ;; I will assume that people generally will put so few | |
1659 ;; matches on numbers that any cleverness will take more | |
1660 ;; time than one would gain. | |
1661 (while articles | |
1662 (when (funcall match-func | |
1663 (or (aref (caar articles) gnus-score-index) 0) | |
1664 match) | |
1665 (when trace | |
1666 (push (cons (car-safe (rassq alist gnus-score-cache)) kill) | |
1667 gnus-score-trace)) | |
1668 (setq found t) | |
1669 (setcdr (car articles) (+ score (cdar articles)))) | |
1670 (setq articles (cdr articles))) | |
1671 ;; Update expire date | |
1672 (cond ((null date)) ;Permanent entry. | |
1673 ((and found gnus-update-score-entry-dates) ;Match, update date. | |
1674 (gnus-score-set 'touched '(t) alist) | |
1675 (setcar (nthcdr 2 kill) now)) | |
1676 ((and expire (< date expire)) ;Old entry, remove. | |
1677 (gnus-score-set 'touched '(t) alist) | |
1678 (setcdr entries (cdr rest)) | |
1679 (setq rest entries))) | |
1680 (setq entries rest))))) | |
1681 nil) | |
1682 | |
1683 (defun gnus-score-date (scores header now expire &optional trace) | |
1684 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index))) | |
1685 entries alist match match-func article) | |
1686 ;; Find matches. | |
1687 (while scores | |
1688 (setq alist (car scores) | |
1689 scores (cdr scores) | |
1690 entries (assoc header alist)) | |
1691 (while (cdr entries) ;First entry is the header index. | |
1692 (let* ((rest (cdr entries)) | |
1693 (kill (car rest)) | |
1694 (type (or (nth 3 kill) 'before)) | |
1695 (score (or (nth 1 kill) gnus-score-interactive-default-score)) | |
1696 (date (nth 2 kill)) | |
1697 (found nil) | |
1698 (articles gnus-scores-articles) | |
1699 l) | |
1700 (cond | |
1701 ((eq type 'after) | |
1702 (setq match-func 'string< | |
1703 match (gnus-date-iso8601 (nth 0 kill)))) | |
1704 ((eq type 'before) | |
1705 (setq match-func 'gnus-string> | |
1706 match (gnus-date-iso8601 (nth 0 kill)))) | |
1707 ((eq type 'at) | |
1708 (setq match-func 'string= | |
1709 match (gnus-date-iso8601 (nth 0 kill)))) | |
1710 ((eq type 'regexp) | |
1711 (setq match-func 'string-match | |
1712 match (nth 0 kill))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1713 (t (error "Invalid match type: %s" type))) |
17493 | 1714 ;; Instead of doing all the clever stuff that |
1715 ;; `gnus-score-string' does to minimize searches and stuff, | |
1716 ;; I will assume that people generally will put so few | |
1717 ;; matches on numbers that any cleverness will take more | |
1718 ;; time than one would gain. | |
1719 (while (setq article (pop articles)) | |
1720 (when (and | |
1721 (setq l (aref (car article) gnus-score-index)) | |
1722 (funcall match-func match (gnus-date-iso8601 l))) | |
1723 (when trace | |
1724 (push (cons (car-safe (rassq alist gnus-score-cache)) kill) | |
1725 gnus-score-trace)) | |
1726 (setq found t) | |
1727 (setcdr article (+ score (cdr article))))) | |
1728 ;; Update expire date | |
1729 (cond ((null date)) ;Permanent entry. | |
1730 ((and found gnus-update-score-entry-dates) ;Match, update date. | |
1731 (gnus-score-set 'touched '(t) alist) | |
1732 (setcar (nthcdr 2 kill) now)) | |
1733 ((and expire (< date expire)) ;Old entry, remove. | |
1734 (gnus-score-set 'touched '(t) alist) | |
1735 (setcdr entries (cdr rest)) | |
1736 (setq rest entries))) | |
1737 (setq entries rest))))) | |
1738 nil) | |
1739 | |
1740 (defun gnus-score-body (scores header now expire &optional trace) | |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1741 (if gnus-agent-fetching |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1742 nil |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1743 (save-excursion |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1744 (setq gnus-scores-articles |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1745 (sort gnus-scores-articles |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1746 (lambda (a1 a2) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1747 (< (mail-header-number (car a1)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1748 (mail-header-number (car a2)))))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1749 (set-buffer nntp-server-buffer) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1750 (save-restriction |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1751 (let* ((buffer-read-only nil) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1752 (articles gnus-scores-articles) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1753 (all-scores scores) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1754 (request-func (cond ((string= "head" header) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1755 'gnus-request-head) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1756 ((string= "body" header) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1757 'gnus-request-body) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1758 (t 'gnus-request-article))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1759 entries alist ofunc article last) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1760 (when articles |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1761 (setq last (mail-header-number (caar (last articles)))) |
17493 | 1762 ;; Not all backends support partial fetching. In that case, |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1763 ;; we just fetch the entire article. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1764 (unless (gnus-check-backend-function |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1765 (and (string-match "^gnus-" (symbol-name request-func)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1766 (intern (substring (symbol-name request-func) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1767 (match-end 0)))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1768 gnus-newsgroup-name) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1769 (setq ofunc request-func) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1770 (setq request-func 'gnus-request-article)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1771 (while articles |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1772 (setq article (mail-header-number (caar articles))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1773 (gnus-message 7 "Scoring article %s of %s..." article last) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1774 (widen) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1775 (when (funcall request-func article gnus-newsgroup-name) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1776 (goto-char (point-min)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1777 ;; If just parts of the article is to be searched, but the |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1778 ;; backend didn't support partial fetching, we just narrow |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1779 ;; to the relevant parts. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1780 (when ofunc |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1781 (if (eq ofunc 'gnus-request-head) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1782 (narrow-to-region |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1783 (point) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1784 (or (search-forward "\n\n" nil t) (point-max))) |
17493 | 1785 (narrow-to-region |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1786 (or (search-forward "\n\n" nil t) (point)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1787 (point-max)))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1788 (setq scores all-scores) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1789 ;; Find matches. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1790 (while scores |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1791 (setq alist (pop scores) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1792 entries (assoc header alist)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1793 (while (cdr entries) ;First entry is the header index. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1794 (let* ((rest (cdr entries)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1795 (kill (car rest)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1796 (match (nth 0 kill)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1797 (type (or (nth 3 kill) 's)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1798 (score (or (nth 1 kill) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1799 gnus-score-interactive-default-score)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1800 (date (nth 2 kill)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1801 (found nil) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1802 (case-fold-search |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1803 (not (or (eq type 'R) (eq type 'S) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1804 (eq type 'Regexp) (eq type 'String)))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1805 (search-func |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1806 (cond ((or (eq type 'r) (eq type 'R) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1807 (eq type 'regexp) (eq type 'Regexp)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1808 're-search-forward) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1809 ((or (eq type 's) (eq type 'S) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1810 (eq type 'string) (eq type 'String)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1811 'search-forward) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1812 (t |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1813 (error "Invalid match type: %s" type))))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1814 (goto-char (point-min)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1815 (when (funcall search-func match nil t) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1816 ;; Found a match, update scores. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1817 (setcdr (car articles) (+ score (cdar articles))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1818 (setq found t) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1819 (when trace |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1820 (push |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1821 (cons (car-safe (rassq alist gnus-score-cache)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1822 kill) |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1823 gnus-score-trace))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1824 ;; Update expire date |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1825 (unless trace |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1826 (cond |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1827 ((null date)) ;Permanent entry. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1828 ((and found gnus-update-score-entry-dates) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1829 ;; Match, update date. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1830 (gnus-score-set 'touched '(t) alist) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1831 (setcar (nthcdr 2 kill) now)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1832 ((and expire (< date expire)) ;Old entry, remove. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1833 (gnus-score-set 'touched '(t) alist) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1834 (setcdr entries (cdr rest)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1835 (setq rest entries)))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1836 (setq entries rest))))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1837 (setq articles (cdr articles))))))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1838 nil)) |
17493 | 1839 |
1840 (defun gnus-score-thread (scores header now expire &optional trace) | |
1841 (gnus-score-followup scores header now expire trace t)) | |
1842 | |
1843 (defun gnus-score-followup (scores header now expire &optional trace thread) | |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1844 (if gnus-agent-fetching |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1845 ;; FIXME: It seems doable in fetching mode. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1846 nil |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1847 ;; Insert the unique article headers in the buffer. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1848 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1849 (current-score-file gnus-current-score-file) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1850 (all-scores scores) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1851 ;; gnus-score-index is used as a free variable. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1852 alike last this art entries alist articles |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1853 new news) |
35838
53eebdb81828
2001-02-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33319
diff
changeset
|
1854 |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1855 ;; Change score file to the adaptive score file. All entries that |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1856 ;; this function makes will be put into this file. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1857 (save-excursion |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1858 (set-buffer gnus-summary-buffer) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1859 (gnus-score-load-file |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1860 (or gnus-newsgroup-adaptive-score-file |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1861 (gnus-score-file-name |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1862 gnus-newsgroup-name gnus-adaptive-file-suffix)))) |
17493 | 1863 |
35838
53eebdb81828
2001-02-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33319
diff
changeset
|
1864 (setq gnus-scores-articles (sort gnus-scores-articles |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1865 'gnus-score-string<) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1866 articles gnus-scores-articles) |
17493 | 1867 |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1868 (erase-buffer) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1869 (while articles |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1870 (setq art (car articles) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1871 this (aref (car art) gnus-score-index) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1872 articles (cdr articles)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1873 (if (equal last this) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1874 (push art alike) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1875 (when last |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1876 (insert last ?\n) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1877 (put-text-property (1- (point)) (point) 'articles alike)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1878 (setq alike (list art) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1879 last this))) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1880 (when last ; Bwadr, duplicate code. |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1881 (insert last ?\n) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1882 (put-text-property (1- (point)) (point) 'articles alike)) |
17493 | 1883 |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1884 ;; Find matches. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1885 (while scores |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1886 (setq alist (car scores) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1887 scores (cdr scores) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1888 entries (assoc header alist)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1889 (while (cdr entries) ;First entry is the header index. |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1890 (let* ((rest (cdr entries)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1891 (kill (car rest)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1892 (match (nth 0 kill)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1893 (type (or (nth 3 kill) 's)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1894 (score (or (nth 1 kill) gnus-score-interactive-default-score)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1895 (date (nth 2 kill)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1896 (found nil) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1897 (mt (aref (symbol-name type) 0)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1898 (case-fold-search |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1899 (not (or (= mt ?R) (= mt ?S) (= mt ?E) (= mt ?F)))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1900 (dmt (downcase mt)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1901 (search-func |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1902 (cond ((= dmt ?r) 're-search-forward) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1903 ((or (= dmt ?e) (= dmt ?s) (= dmt ?f)) 'search-forward) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1904 (t (error "Invalid match type: %s" type)))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1905 arts art) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1906 (goto-char (point-min)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1907 (if (= dmt ?e) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1908 (while (funcall search-func match nil t) |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
1909 (and (= (point-at-bol) |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1910 (match-beginning 0)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1911 (= (progn (end-of-line) (point)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1912 (match-end 0)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1913 (progn |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1914 (setq found (setq arts (get-text-property |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1915 (point) 'articles))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1916 ;; Found a match, update scores. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1917 (while arts |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1918 (setq art (car arts) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1919 arts (cdr arts)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1920 (gnus-score-add-followups |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1921 (car art) score all-scores thread)))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1922 (end-of-line)) |
17493 | 1923 (while (funcall search-func match nil t) |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1924 (end-of-line) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1925 (setq found (setq arts (get-text-property (point) 'articles))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1926 ;; Found a match, update scores. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1927 (while (setq art (pop arts)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1928 (setcdr art (+ score (cdr art))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1929 (when trace |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1930 (push (cons |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1931 (car-safe (rassq alist gnus-score-cache)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1932 kill) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1933 gnus-score-trace)) |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1934 (when (setq new (gnus-score-add-followups |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1935 (car art) score all-scores thread)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1936 (push new news))))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1937 ;; Update expire date |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1938 (cond ((null date)) ;Permanent entry. |
35838
53eebdb81828
2001-02-01 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33319
diff
changeset
|
1939 ((and found gnus-update-score-entry-dates) |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1940 ;Match, update date. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1941 (gnus-score-set 'touched '(t) alist) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1942 (setcar (nthcdr 2 kill) now)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1943 ((and expire (< date expire)) ;Old entry, remove. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1944 (gnus-score-set 'touched '(t) alist) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1945 (setcdr entries (cdr rest)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1946 (setq rest entries))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1947 (setq entries rest)))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1948 ;; We change the score file back to the previous one. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1949 (save-excursion |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1950 (set-buffer gnus-summary-buffer) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1951 (gnus-score-load-file current-score-file)) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1952 (list (cons "references" news))))) |
17493 | 1953 |
1954 (defun gnus-score-add-followups (header score scores &optional thread) | |
1955 "Add a score entry to the adapt file." | |
1956 (save-excursion | |
1957 (set-buffer gnus-summary-buffer) | |
1958 (let* ((id (mail-header-id header)) | |
1959 (scores (car scores)) | |
1960 entry dont) | |
1961 ;; Don't enter a score if there already is one. | |
1962 (while (setq entry (pop scores)) | |
1963 (and (equal "references" (car entry)) | |
1964 (or (null (nth 3 (cadr entry))) | |
1965 (eq 's (nth 3 (cadr entry)))) | |
1966 (assoc id entry) | |
1967 (setq dont t))) | |
1968 (unless dont | |
1969 (gnus-summary-score-entry | |
1970 (if thread "thread" "references") | |
1971 id 's score (current-time-string) nil t))))) | |
1972 | |
1973 (defun gnus-score-string (score-list header now expire &optional trace) | |
1974 ;; Score ARTICLES according to HEADER in SCORE-LIST. | |
1975 ;; Update matching entries to NOW and remove unmatched entries older | |
1976 ;; than EXPIRE. | |
1977 | |
1978 ;; Insert the unique article headers in the buffer. | |
1979 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index))) | |
1980 ;; gnus-score-index is used as a free variable. | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1981 (simplify (and gnus-score-thread-simplify |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
1982 (string= "subject" header))) |
17493 | 1983 alike last this art entries alist articles |
1984 fuzzies arts words kill) | |
1985 | |
1986 ;; Sorting the articles costs os O(N*log N) but will allow us to | |
1987 ;; only match with each unique header. Thus the actual matching | |
1988 ;; will be O(M*U) where M is the number of strings to match with, | |
1989 ;; and U is the number of unique headers. It is assumed (but | |
1990 ;; untested) this will be a net win because of the large constant | |
1991 ;; factor involved with string matching. | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1992 (setq gnus-scores-articles |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1993 ;; We cannot string-sort the extra headers list. *sigh* |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1994 (if (= gnus-score-index 9) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1995 gnus-scores-articles |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1996 (sort gnus-scores-articles 'gnus-score-string<)) |
17493 | 1997 articles gnus-scores-articles) |
1998 | |
1999 (erase-buffer) | |
2000 (while (setq art (pop articles)) | |
2001 (setq this (aref (car art) gnus-score-index)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2002 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2003 ;; If we're working with non-standard headers, we are stuck |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2004 ;; with working on them as a group. What a hassle. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2005 ;; Just wait 'til you see what horrors we commit against `match'... |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2006 (if (= gnus-score-index 9) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2007 (setq this (gnus-prin1-to-string this))) ; ick. |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2008 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2009 (if simplify |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2010 (setq this (gnus-map-function gnus-simplify-subject-functions this))) |
17493 | 2011 (if (equal last this) |
2012 ;; O(N*H) cons-cells used here, where H is the number of | |
2013 ;; headers. | |
2014 (push art alike) | |
2015 (when last | |
2016 ;; Insert the line, with a text property on the | |
2017 ;; terminating newline referring to the articles with | |
2018 ;; this line. | |
2019 (insert last ?\n) | |
2020 (put-text-property (1- (point)) (point) 'articles alike)) | |
2021 (setq alike (list art) | |
2022 last this))) | |
2023 (when last ; Bwadr, duplicate code. | |
2024 (insert last ?\n) | |
2025 (put-text-property (1- (point)) (point) 'articles alike)) | |
2026 | |
2027 ;; Go through all the score alists and pick out the entries | |
2028 ;; for this header. | |
2029 (while score-list | |
2030 (setq alist (pop score-list) | |
2031 ;; There's only one instance of this header for | |
2032 ;; each score alist. | |
2033 entries (assoc header alist)) | |
2034 (while (cdr entries) ;First entry is the header index. | |
2035 (let* ((kill (cadr entries)) | |
2036 (type (or (nth 3 kill) 's)) | |
2037 (score (or (nth 1 kill) gnus-score-interactive-default-score)) | |
2038 (date (nth 2 kill)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2039 (extra (nth 4 kill)) ; non-standard header; string. |
17493 | 2040 (found nil) |
2041 (mt (aref (symbol-name type) 0)) | |
2042 (case-fold-search (not (memq mt '(?R ?S ?E ?F)))) | |
2043 (dmt (downcase mt)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2044 ;; Assume user already simplified regexp and fuzzies |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2045 (match (if (and simplify (not (memq dmt '(?f ?r)))) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2046 (gnus-map-function |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2047 gnus-simplify-subject-functions |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2048 (nth 0 kill)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2049 (nth 0 kill))) |
17493 | 2050 (search-func |
2051 (cond ((= dmt ?r) 're-search-forward) | |
2052 ((or (= dmt ?e) (= dmt ?s) (= dmt ?f)) 'search-forward) | |
2053 ((= dmt ?w) nil) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2054 (t (error "Invalid match type: %s" type))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2055 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2056 ;; Evil hackery to make match usable in non-standard headers. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2057 (when extra |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2058 (setq match (concat "[ (](" extra " \\. \"[^)]*" |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2059 match "[^\"]*\")[ )]") |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2060 search-func 're-search-forward)) ; XXX danger?!? |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2061 |
17493 | 2062 (cond |
2063 ;; Fuzzy matches. We save these for later. | |
2064 ((= dmt ?f) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2065 (push (cons entries alist) fuzzies) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2066 (setq entries (cdr entries))) |
17493 | 2067 ;; Word matches. Save these for even later. |
2068 ((= dmt ?w) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2069 (push (cons entries alist) words) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2070 (setq entries (cdr entries))) |
17493 | 2071 ;; Exact matches. |
2072 ((= dmt ?e) | |
2073 ;; Do exact matching. | |
2074 (goto-char (point-min)) | |
2075 (while (and (not (eobp)) | |
2076 (funcall search-func match nil t)) | |
2077 ;; Is it really exact? | |
2078 (and (eolp) | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2079 (= (point-at-bol) (match-beginning 0)) |
17493 | 2080 ;; Yup. |
2081 (progn | |
2082 (setq found (setq arts (get-text-property | |
2083 (point) 'articles))) | |
2084 ;; Found a match, update scores. | |
2085 (if trace | |
2086 (while (setq art (pop arts)) | |
2087 (setcdr art (+ score (cdr art))) | |
2088 (push | |
2089 (cons | |
2090 (car-safe (rassq alist gnus-score-cache)) | |
2091 kill) | |
2092 gnus-score-trace)) | |
2093 (while (setq art (pop arts)) | |
2094 (setcdr art (+ score (cdr art))))))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2095 (forward-line 1)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2096 ;; Update expiry date |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2097 (if trace |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2098 (setq entries (cdr entries)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2099 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2100 ;; Permanent entry. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2101 ((null date) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2102 (setq entries (cdr entries))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2103 ;; We have a match, so we update the date. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2104 ((and found gnus-update-score-entry-dates) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2105 (gnus-score-set 'touched '(t) alist) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2106 (setcar (nthcdr 2 kill) now) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2107 (setq entries (cdr entries))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2108 ;; This entry has expired, so we remove it. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2109 ((and expire (< date expire)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2110 (gnus-score-set 'touched '(t) alist) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2111 (setcdr entries (cddr entries))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2112 ;; No match; go to next entry. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2113 (t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2114 (setq entries (cdr entries)))))) |
17493 | 2115 ;; Regexp and substring matching. |
2116 (t | |
2117 (goto-char (point-min)) | |
2118 (when (string= match "") | |
2119 (setq match "\n")) | |
2120 (while (and (not (eobp)) | |
2121 (funcall search-func match nil t)) | |
2122 (goto-char (match-beginning 0)) | |
2123 (end-of-line) | |
2124 (setq found (setq arts (get-text-property (point) 'articles))) | |
2125 ;; Found a match, update scores. | |
2126 (if trace | |
2127 (while (setq art (pop arts)) | |
2128 (setcdr art (+ score (cdr art))) | |
2129 (push (cons (car-safe (rassq alist gnus-score-cache)) kill) | |
2130 gnus-score-trace)) | |
2131 (while (setq art (pop arts)) | |
2132 (setcdr art (+ score (cdr art))))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2133 (forward-line 1)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2134 ;; Update expiry date |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2135 (if trace |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2136 (setq entries (cdr entries)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2137 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2138 ;; Permanent entry. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2139 ((null date) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2140 (setq entries (cdr entries))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2141 ;; We have a match, so we update the date. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2142 ((and found gnus-update-score-entry-dates) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2143 (gnus-score-set 'touched '(t) alist) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2144 (setcar (nthcdr 2 kill) now) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2145 (setq entries (cdr entries))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2146 ;; This entry has expired, so we remove it. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2147 ((and expire (< date expire)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2148 (gnus-score-set 'touched '(t) alist) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2149 (setcdr entries (cddr entries))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2150 ;; No match; go to next entry. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2151 (t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2152 (setq entries (cdr entries)))))))))) |
17493 | 2153 |
2154 ;; Find fuzzy matches. | |
2155 (when fuzzies | |
2156 ;; Simplify the entire buffer for easy matching. | |
2157 (gnus-simplify-buffer-fuzzy) | |
2158 (while (setq kill (cadaar fuzzies)) | |
2159 (let* ((match (nth 0 kill)) | |
2160 (type (nth 3 kill)) | |
2161 (score (or (nth 1 kill) gnus-score-interactive-default-score)) | |
2162 (date (nth 2 kill)) | |
2163 (mt (aref (symbol-name type) 0)) | |
2164 (case-fold-search (not (= mt ?F))) | |
2165 found) | |
2166 (goto-char (point-min)) | |
2167 (while (and (not (eobp)) | |
2168 (search-forward match nil t)) | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2169 (when (and (= (point-at-bol) (match-beginning 0)) |
17493 | 2170 (eolp)) |
2171 (setq found (setq arts (get-text-property (point) 'articles))) | |
2172 (if trace | |
2173 (while (setq art (pop arts)) | |
2174 (setcdr art (+ score (cdr art))) | |
2175 (push (cons | |
2176 (car-safe (rassq (cdar fuzzies) gnus-score-cache)) | |
2177 kill) | |
2178 gnus-score-trace)) | |
2179 ;; Found a match, update scores. | |
2180 (while (setq art (pop arts)) | |
2181 (setcdr art (+ score (cdr art)))))) | |
2182 (forward-line 1)) | |
2183 ;; Update expiry date | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2184 (if (not trace) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2185 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2186 ;; Permanent. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2187 ((null date) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2188 ;; Do nothing. |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2189 ) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2190 ;; Match, update date. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2191 ((and found gnus-update-score-entry-dates) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2192 (gnus-score-set 'touched '(t) (cdar fuzzies)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2193 (setcar (nthcdr 2 kill) now)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2194 ;; Old entry, remove. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2195 ((and expire (< date expire)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2196 (gnus-score-set 'touched '(t) (cdar fuzzies)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2197 (setcdr (caar fuzzies) (cddaar fuzzies))))) |
17493 | 2198 (setq fuzzies (cdr fuzzies))))) |
2199 | |
2200 (when words | |
2201 ;; Enter all words into the hashtb. | |
2202 (let ((hashtb (gnus-make-hashtable | |
2203 (* 10 (count-lines (point-min) (point-max)))))) | |
2204 (gnus-enter-score-words-into-hashtb hashtb) | |
2205 (while (setq kill (cadaar words)) | |
2206 (let* ((score (or (nth 1 kill) gnus-score-interactive-default-score)) | |
2207 (date (nth 2 kill)) | |
2208 found) | |
2209 (when (setq arts (intern-soft (nth 0 kill) hashtb)) | |
2210 (setq arts (symbol-value arts)) | |
2211 (setq found t) | |
2212 (if trace | |
2213 (while (setq art (pop arts)) | |
2214 (setcdr art (+ score (cdr art))) | |
2215 (push (cons | |
2216 (car-safe (rassq (cdar words) gnus-score-cache)) | |
2217 kill) | |
2218 gnus-score-trace)) | |
2219 ;; Found a match, update scores. | |
2220 (while (setq art (pop arts)) | |
2221 (setcdr art (+ score (cdr art)))))) | |
2222 ;; Update expiry date | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2223 (if (not trace) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2224 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2225 ;; Permanent. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2226 ((null date) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2227 ;; Do nothing. |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2228 ) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2229 ;; Match, update date. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2230 ((and found gnus-update-score-entry-dates) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2231 (gnus-score-set 'touched '(t) (cdar words)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2232 (setcar (nthcdr 2 kill) now)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2233 ;; Old entry, remove. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2234 ((and expire (< date expire)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2235 (gnus-score-set 'touched '(t) (cdar words)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2236 (setcdr (caar words) (cddaar words))))) |
17493 | 2237 (setq words (cdr words)))))) |
2238 nil)) | |
2239 | |
2240 (defun gnus-enter-score-words-into-hashtb (hashtb) | |
2241 ;; Find all the words in the buffer and enter them into | |
2242 ;; the hashtable. | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2243 (let (word val) |
17493 | 2244 (goto-char (point-min)) |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2245 (with-syntax-table gnus-adaptive-word-syntax-table |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2246 (while (re-search-forward "\\b\\w+\\b" nil t) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2247 (setq val |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2248 (gnus-gethash |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2249 (setq word (downcase (buffer-substring |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2250 (match-beginning 0) (match-end 0)))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2251 hashtb)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2252 (gnus-sethash |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2253 word |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2254 (append (get-text-property (point-at-eol) 'articles) val) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2255 hashtb))) |
17493 | 2256 ;; Make all the ignorable words ignored. |
2257 (let ((ignored (append gnus-ignored-adaptive-words | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2258 (if gnus-adaptive-word-no-group-words |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2259 (message-tokenize-header |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2260 (gnus-group-real-name gnus-newsgroup-name) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2261 ".")) |
17493 | 2262 gnus-default-ignored-adaptive-words))) |
2263 (while ignored | |
2264 (gnus-sethash (pop ignored) nil hashtb))))) | |
2265 | |
2266 (defun gnus-score-string< (a1 a2) | |
2267 ;; Compare headers in articles A2 and A2. | |
2268 ;; The header index used is the free variable `gnus-score-index'. | |
2269 (string-lessp (aref (car a1) gnus-score-index) | |
2270 (aref (car a2) gnus-score-index))) | |
2271 | |
2272 (defun gnus-current-score-file-nondirectory (&optional score-file) | |
2273 (let ((score-file (or score-file gnus-current-score-file))) | |
2274 (if score-file | |
2275 (gnus-short-group-name (file-name-nondirectory score-file)) | |
2276 "none"))) | |
2277 | |
2278 (defun gnus-score-adaptive () | |
2279 "Create adaptive score rules for this newsgroup." | |
2280 (when gnus-newsgroup-adaptive | |
2281 ;; We change the score file to the adaptive score file. | |
2282 (save-excursion | |
2283 (set-buffer gnus-summary-buffer) | |
2284 (gnus-score-load-file | |
2285 (or gnus-newsgroup-adaptive-score-file | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2286 (gnus-home-score-file gnus-newsgroup-name t) |
17493 | 2287 (gnus-score-file-name |
2288 gnus-newsgroup-name gnus-adaptive-file-suffix)))) | |
2289 ;; Perform ordinary line scoring. | |
2290 (when (or (not (listp gnus-newsgroup-adaptive)) | |
2291 (memq 'line gnus-newsgroup-adaptive)) | |
2292 (save-excursion | |
2293 (let* ((malist (gnus-copy-sequence gnus-adaptive-score-alist)) | |
2294 (alist malist) | |
2295 (date (current-time-string)) | |
2296 (data gnus-newsgroup-data) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2297 elem headers match func) |
17493 | 2298 ;; First we transform the adaptive rule alist into something |
2299 ;; that's faster to process. | |
2300 (while malist | |
2301 (setq elem (car malist)) | |
2302 (when (symbolp (car elem)) | |
2303 (setcar elem (symbol-value (car elem)))) | |
2304 (setq elem (cdr elem)) | |
2305 (while elem | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2306 (when (fboundp |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2307 (setq func |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2308 (intern |
17493 | 2309 (concat "mail-header-" |
2310 (if (eq (caar elem) 'followup) | |
2311 "message-id" | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2312 (downcase (symbol-name (caar elem)))))))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2313 (setcdr (car elem) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2314 (cons (if (eq (caar elem) 'followup) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2315 "references" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2316 (symbol-name (caar elem))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2317 (cdar elem))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2318 (setcar (car elem) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2319 `(lambda (h) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2320 (,func h)))) |
17493 | 2321 (setq elem (cdr elem))) |
2322 (setq malist (cdr malist))) | |
2323 ;; Then we score away. | |
2324 (while data | |
2325 (setq elem (cdr (assq (gnus-data-mark (car data)) alist))) | |
2326 (if (or (not elem) | |
2327 (gnus-data-pseudo-p (car data))) | |
2328 () | |
2329 (when (setq headers (gnus-data-header (car data))) | |
2330 (while elem | |
2331 (setq match (funcall (caar elem) headers)) | |
2332 (gnus-summary-score-entry | |
2333 (nth 1 (car elem)) match | |
2334 (cond | |
2335 ((numberp match) | |
2336 '=) | |
2337 ((equal (nth 1 (car elem)) "date") | |
2338 'a) | |
2339 (t | |
2340 ;; Whether we use substring or exact matches is | |
2341 ;; controlled here. | |
2342 (if (or (not gnus-score-exact-adapt-limit) | |
2343 (< (length match) gnus-score-exact-adapt-limit)) | |
2344 'e | |
2345 (if (equal (nth 1 (car elem)) "subject") | |
2346 'f 's)))) | |
2347 (nth 2 (car elem)) date nil t) | |
2348 (setq elem (cdr elem))))) | |
2349 (setq data (cdr data)))))) | |
2350 | |
2351 ;; Perform adaptive word scoring. | |
2352 (when (and (listp gnus-newsgroup-adaptive) | |
2353 (memq 'word gnus-newsgroup-adaptive)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2354 (with-temp-buffer |
17493 | 2355 (let* ((hashtb (gnus-make-hashtable 1000)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2356 (date (date-to-day (current-time-string))) |
17493 | 2357 (data gnus-newsgroup-data) |
2358 word d score val) | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2359 (with-syntax-table gnus-adaptive-word-syntax-table |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2360 ;; Go through all articles. |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2361 (while (setq d (pop data)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2362 (when (and |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2363 (not (gnus-data-pseudo-p d)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2364 (setq score |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2365 (cdr (assq |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2366 (gnus-data-mark d) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2367 gnus-adaptive-word-score-alist)))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2368 ;; This article has a mark that should lead to |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2369 ;; adaptive word rules, so we insert the subject |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2370 ;; and find all words in that string. |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2371 (insert (mail-header-subject (gnus-data-header d))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2372 (downcase-region (point-min) (point-max)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2373 (goto-char (point-min)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2374 (while (re-search-forward "\\b\\w+\\b" nil t) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2375 ;; Put the word and score into the hashtb. |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2376 (setq val (gnus-gethash (setq word (match-string 0)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2377 hashtb)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2378 (when (or (not gnus-adaptive-word-length-limit) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2379 (> (length word) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2380 gnus-adaptive-word-length-limit)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2381 (setq val (+ score (or val 0))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2382 (if (and gnus-adaptive-word-minimum |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2383 (< val gnus-adaptive-word-minimum)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2384 (setq val gnus-adaptive-word-minimum)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2385 (gnus-sethash word val hashtb))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2386 (erase-buffer)))) |
17493 | 2387 ;; Make all the ignorable words ignored. |
2388 (let ((ignored (append gnus-ignored-adaptive-words | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2389 (if gnus-adaptive-word-no-group-words |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2390 (message-tokenize-header |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2391 (gnus-group-real-name |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2392 gnus-newsgroup-name) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2393 ".")) |
17493 | 2394 gnus-default-ignored-adaptive-words))) |
2395 (while ignored | |
2396 (gnus-sethash (pop ignored) nil hashtb))) | |
2397 ;; Now we have all the words and scores, so we | |
2398 ;; add these rules to the ADAPT file. | |
2399 (set-buffer gnus-summary-buffer) | |
2400 (mapatoms | |
2401 (lambda (word) | |
2402 (when (symbol-value word) | |
2403 (gnus-summary-score-entry | |
2404 "subject" (symbol-name word) 'w (symbol-value word) | |
2405 date nil t))) | |
2406 hashtb)))))) | |
2407 | |
2408 (defun gnus-score-edit-done () | |
2409 (let ((bufnam (buffer-file-name (current-buffer))) | |
2410 (winconf gnus-prev-winconf)) | |
2411 (when winconf | |
2412 (set-window-configuration winconf)) | |
2413 (gnus-score-remove-from-cache bufnam) | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2414 (gnus-score-load-file bufnam) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2415 (run-hooks 'gnus-score-edit-done-hook))) |
17493 | 2416 |
2417 (defun gnus-score-find-trace () | |
2418 "Find all score rules that applies to the current article." | |
2419 (interactive) | |
2420 (let ((old-scored gnus-newsgroup-scored)) | |
2421 (let ((gnus-newsgroup-headers | |
2422 (list (gnus-summary-article-header))) | |
2423 (gnus-newsgroup-scored nil) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2424 ;; Must be synced with `gnus-score-edit-file-at-point': |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2425 (frmt "%S [%s] -> %s\n") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2426 trace |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2427 file) |
17493 | 2428 (save-excursion |
2429 (nnheader-set-temp-buffer "*Score Trace*")) | |
2430 (setq gnus-score-trace nil) | |
2431 (gnus-possibly-score-headers 'trace) | |
2432 (if (not (setq trace gnus-score-trace)) | |
2433 (gnus-error | |
2434 1 "No score rules apply to the current article (default score %d)." | |
2435 gnus-summary-default-score) | |
2436 (set-buffer "*Score Trace*") | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2437 ;; Use a keymap instead? |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2438 (local-set-key "q" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2439 (lambda () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2440 (interactive) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2441 (bury-buffer nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2442 (gnus-summary-expand-window))) |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2443 (local-set-key "k" |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2444 (lambda () |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2445 (interactive) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2446 (kill-buffer (current-buffer)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2447 (gnus-summary-expand-window))) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2448 (local-set-key "e" (lambda () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2449 "Run `gnus-score-edit-file-at-point'." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2450 (interactive) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2451 (gnus-score-edit-file-at-point))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2452 (local-set-key "f" (lambda () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2453 "Run `gnus-score-edit-file-at-point'." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2454 (interactive) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2455 (gnus-score-edit-file-at-point 'format))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2456 (local-set-key "t" 'toggle-truncate-lines) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2457 (setq truncate-lines t) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2458 (dolist (entry trace) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2459 (setq file (or (car entry) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2460 ;; Must be synced with |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2461 ;; `gnus-score-edit-file-at-point': |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2462 "(non-file rule)")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2463 (insert |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2464 (format frmt |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2465 (cdr entry) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2466 ;; Don't use `file-name-sans-extension' to see .SCORE and |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2467 ;; .ADAPT directly: |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2468 (file-name-nondirectory file) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2469 (abbreviate-file-name file)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2470 (insert |
96498 | 2471 (format "\nTotal score: %d" |
2472 (apply '+ (mapcar 'caddr trace)))) | |
2473 (insert | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2474 "\n\nQuick help: |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2475 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2476 Type `e' to edit score file corresponding to the score rule on current line, |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2477 `f' to format (pretty print) the score file and edit it, |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2478 `t' toggle to truncate long lines in this buffer, |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2479 `q' to quit, `k' to kill score trace buffer. |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2480 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2481 The first sexp on each line is the score rule, followed by the file name of |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2482 the score file and its full name, including the directory.") |
17493 | 2483 (goto-char (point-min)) |
2484 (gnus-configure-windows 'score-trace))) | |
2485 (set-buffer gnus-summary-buffer) | |
2486 (setq gnus-newsgroup-scored old-scored))) | |
2487 | |
2488 (defun gnus-score-find-favourite-words () | |
2489 "List words used in scoring." | |
2490 (interactive) | |
2491 (let ((alists (gnus-score-load-files (gnus-all-score-files))) | |
2492 alist rule rules kill) | |
2493 ;; Go through all the score alists for this group | |
2494 ;; and find all `w' rules. | |
2495 (while (setq alist (pop alists)) | |
2496 (while (setq rule (pop alist)) | |
2497 (when (and (stringp (car rule)) | |
2498 (equal "subject" (downcase (pop rule)))) | |
2499 (while (setq kill (pop rule)) | |
2500 (when (memq (nth 3 kill) '(w W word Word)) | |
2501 (push (cons (or (nth 1 kill) | |
2502 gnus-score-interactive-default-score) | |
2503 (car kill)) | |
2504 rules)))))) | |
2505 (setq rules (sort rules (lambda (r1 r2) | |
2506 (string-lessp (cdr r1) (cdr r2))))) | |
2507 ;; Add up words that have appeared several times. | |
2508 (let ((r rules)) | |
2509 (while (cdr r) | |
2510 (if (equal (cdar r) (cdadr r)) | |
2511 (progn | |
2512 (setcar (car r) (+ (caar r) (caadr r))) | |
2513 (setcdr r (cddr r))) | |
2514 (pop r)))) | |
2515 ;; Insert the words. | |
2516 (nnheader-set-temp-buffer "*Score Words*") | |
2517 (if (not (setq rules (sort rules (lambda (r1 r2) (> (car r1) (car r2)))))) | |
2518 (gnus-error 3 "No word score rules") | |
2519 (while rules | |
2520 (insert (format "%-5d: %s\n" (caar rules) (cdar rules))) | |
2521 (pop rules)) | |
2522 (goto-char (point-min)) | |
2523 (gnus-configure-windows 'score-words)))) | |
2524 | |
2525 (defun gnus-summary-rescore () | |
2526 "Redo the entire scoring process in the current summary." | |
2527 (interactive) | |
2528 (gnus-score-save) | |
2529 (setq gnus-score-cache nil) | |
2530 (setq gnus-newsgroup-scored nil) | |
2531 (gnus-possibly-score-headers) | |
2532 (gnus-score-update-all-lines)) | |
2533 | |
2534 (defun gnus-score-flush-cache () | |
2535 "Flush the cache of score files." | |
2536 (interactive) | |
2537 (gnus-score-save) | |
2538 (setq gnus-score-cache nil | |
2539 gnus-score-alist nil | |
2540 gnus-short-name-score-file-cache nil) | |
2541 (gnus-message 6 "The score cache is now flushed")) | |
2542 | |
2543 (gnus-add-shutdown 'gnus-score-close 'gnus) | |
2544 | |
2545 (defvar gnus-score-file-alist-cache nil) | |
2546 | |
2547 (defun gnus-score-close () | |
2548 "Clear all internal score variables." | |
2549 (setq gnus-score-cache nil | |
2550 gnus-internal-global-score-files nil | |
2551 gnus-score-file-list nil | |
2552 gnus-score-file-alist-cache nil)) | |
2553 | |
2554 ;; Summary score marking commands. | |
2555 | |
2556 (defun gnus-summary-raise-same-subject-and-select (score) | |
2557 "Raise articles which has the same subject with SCORE and select the next." | |
2558 (interactive "p") | |
2559 (let ((subject (gnus-summary-article-subject))) | |
2560 (gnus-summary-raise-score score) | |
2561 (while (gnus-summary-find-subject subject) | |
2562 (gnus-summary-raise-score score)) | |
2563 (gnus-summary-next-article t))) | |
2564 | |
2565 (defun gnus-summary-raise-same-subject (score) | |
2566 "Raise articles which has the same subject with SCORE." | |
2567 (interactive "p") | |
2568 (let ((subject (gnus-summary-article-subject))) | |
2569 (gnus-summary-raise-score score) | |
2570 (while (gnus-summary-find-subject subject) | |
2571 (gnus-summary-raise-score score)) | |
2572 (gnus-summary-next-subject 1 t))) | |
2573 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2574 (defun gnus-score-delta-default (level) |
17493 | 2575 (if level (prefix-numeric-value level) |
2576 gnus-score-interactive-default-score)) | |
2577 | |
2578 (defun gnus-summary-raise-thread (&optional score) | |
2579 "Raise the score of the articles in the current thread with SCORE." | |
2580 (interactive "P") | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2581 (setq score (gnus-score-delta-default score)) |
17493 | 2582 (let (e) |
2583 (save-excursion | |
2584 (let ((articles (gnus-summary-articles-in-thread))) | |
2585 (while articles | |
2586 (gnus-summary-goto-subject (car articles)) | |
2587 (gnus-summary-raise-score score) | |
2588 (setq articles (cdr articles)))) | |
2589 (setq e (point))) | |
2590 (let ((gnus-summary-check-current t)) | |
2591 (unless (zerop (gnus-summary-next-subject 1 t)) | |
2592 (goto-char e)))) | |
2593 (gnus-summary-recenter) | |
2594 (gnus-summary-position-point) | |
2595 (gnus-set-mode-line 'summary)) | |
2596 | |
2597 (defun gnus-summary-lower-same-subject-and-select (score) | |
2598 "Raise articles which has the same subject with SCORE and select the next." | |
2599 (interactive "p") | |
2600 (gnus-summary-raise-same-subject-and-select (- score))) | |
2601 | |
2602 (defun gnus-summary-lower-same-subject (score) | |
2603 "Raise articles which has the same subject with SCORE." | |
2604 (interactive "p") | |
2605 (gnus-summary-raise-same-subject (- score))) | |
2606 | |
2607 (defun gnus-summary-lower-thread (&optional score) | |
2608 "Lower score of articles in the current thread with SCORE." | |
2609 (interactive "P") | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2610 (gnus-summary-raise-thread (- (gnus-score-delta-default score)))) |
17493 | 2611 |
2612 ;;; Finding score files. | |
2613 | |
2614 (defun gnus-score-score-files (group) | |
2615 "Return a list of all possible score files." | |
2616 ;; Search and set any global score files. | |
2617 (when gnus-global-score-files | |
2618 (unless gnus-internal-global-score-files | |
2619 (gnus-score-search-global-directories gnus-global-score-files))) | |
2620 ;; Fix the kill-file dir variable. | |
2621 (setq gnus-kill-files-directory | |
2622 (file-name-as-directory gnus-kill-files-directory)) | |
2623 ;; If we can't read it, there are no score files. | |
2624 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory))) | |
2625 (setq gnus-score-file-list nil) | |
2626 (if (not (gnus-use-long-file-name 'not-score)) | |
2627 ;; We do not use long file names, so we have to do some | |
2628 ;; directory traversing. | |
2629 (setq gnus-score-file-list | |
2630 (cons nil | |
2631 (or gnus-short-name-score-file-cache | |
2632 (prog2 | |
2633 (gnus-message 6 "Finding all score files...") | |
2634 (setq gnus-short-name-score-file-cache | |
2635 (gnus-score-score-files-1 | |
2636 gnus-kill-files-directory)) | |
2637 (gnus-message 6 "Finding all score files...done"))))) | |
2638 ;; We want long file names. | |
2639 (when (or (not gnus-score-file-list) | |
2640 (not (car gnus-score-file-list)) | |
2641 (gnus-file-newer-than gnus-kill-files-directory | |
2642 (car gnus-score-file-list))) | |
2643 (setq gnus-score-file-list | |
2644 (cons (nth 5 (file-attributes gnus-kill-files-directory)) | |
2645 (nreverse | |
2646 (directory-files | |
2647 gnus-kill-files-directory t | |
2648 (gnus-score-file-regexp))))))) | |
2649 (cdr gnus-score-file-list))) | |
2650 | |
2651 (defun gnus-score-score-files-1 (dir) | |
2652 "Return all possible score files under DIR." | |
2653 (let ((files (list (expand-file-name dir))) | |
2654 (regexp (gnus-score-file-regexp)) | |
2655 (case-fold-search nil) | |
2656 seen out file) | |
2657 (while (setq file (pop files)) | |
2658 (cond | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2659 ;; Ignore files that start with a dot. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2660 ((string-match "^\\." (file-name-nondirectory file)) |
17493 | 2661 nil) |
2662 ;; Add subtrees of directory to also be searched. | |
2663 ((and (file-directory-p file) | |
2664 (not (member (file-truename file) seen))) | |
2665 (push (file-truename file) seen) | |
2666 (setq files (nconc (directory-files file t nil t) files))) | |
2667 ;; Add files to the list of score files. | |
2668 ((string-match regexp file) | |
2669 (push file out)))) | |
2670 (or out | |
2671 ;; Return a dummy value. | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2672 (list (expand-file-name "this.file.does.not.exist.SCORE" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2673 gnus-kill-files-directory))))) |
17493 | 2674 |
2675 (defun gnus-score-file-regexp () | |
2676 "Return a regexp that match all score files." | |
2677 (concat "\\(" (regexp-quote gnus-score-file-suffix ) | |
2678 "\\|" (regexp-quote gnus-adaptive-file-suffix) "\\)\\'")) | |
2679 | |
2680 (defun gnus-score-find-bnews (group) | |
2681 "Return a list of score files for GROUP. | |
2682 The score files are those files in the ~/News/ directory which matches | |
2683 GROUP using BNews sys file syntax." | |
2684 (let* ((sfiles (append (gnus-score-score-files group) | |
2685 gnus-internal-global-score-files)) | |
2686 (kill-dir (file-name-as-directory | |
2687 (expand-file-name gnus-kill-files-directory))) | |
2688 (klen (length kill-dir)) | |
2689 (score-regexp (gnus-score-file-regexp)) | |
2690 (trans (cdr (assq ?: nnheader-file-name-translation-alist))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2691 (group-trans (nnheader-translate-file-chars group t)) |
17493 | 2692 ofiles not-match regexp) |
2693 (save-excursion | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2694 (set-buffer (gnus-get-buffer-create "*gnus score files*")) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2695 (buffer-disable-undo) |
17493 | 2696 ;; Go through all score file names and create regexp with them |
2697 ;; as the source. | |
2698 (while sfiles | |
2699 (erase-buffer) | |
2700 (insert (car sfiles)) | |
2701 (goto-char (point-min)) | |
2702 ;; First remove the suffix itself. | |
2703 (when (re-search-forward (concat "." score-regexp) nil t) | |
2704 (replace-match "" t t) | |
2705 (goto-char (point-min)) | |
2706 (if (looking-at (regexp-quote kill-dir)) | |
2707 ;; If the file name was just "SCORE", `klen' is one character | |
2708 ;; too much. | |
2709 (delete-char (min (1- (point-max)) klen)) | |
2710 (goto-char (point-max)) | |
41494
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
41059
diff
changeset
|
2711 (if (re-search-backward gnus-directory-sep-char-regexp nil t) |
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
41059
diff
changeset
|
2712 (delete-region (1+ (point)) (point-min)) |
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
41059
diff
changeset
|
2713 (gnus-message 1 "Can't find directory separator in %s" |
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
41059
diff
changeset
|
2714 (car sfiles)))) |
17493 | 2715 ;; If short file names were used, we have to translate slashes. |
2716 (goto-char (point-min)) | |
2717 (let ((regexp (concat | |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2718 "[/:" (if trans (char-to-string trans)) "]"))) |
17493 | 2719 (while (re-search-forward regexp nil t) |
2720 (replace-match "." t t))) | |
2721 ;; Kludge to get rid of "nntp+" problems. | |
2722 (goto-char (point-min)) | |
2723 (when (looking-at "nn[a-z]+\\+") | |
2724 (search-forward "+") | |
2725 (forward-char -1) | |
2726 (insert "\\") | |
2727 (forward-char 1)) | |
2728 ;; Kludge to deal with "++". | |
2729 (while (search-forward "+" nil t) | |
2730 (replace-match "\\+" t t)) | |
2731 ;; Translate "all" to ".*". | |
2732 (goto-char (point-min)) | |
2733 (while (search-forward "all" nil t) | |
2734 (replace-match ".*" t t)) | |
2735 (goto-char (point-min)) | |
2736 ;; Deal with "not."s. | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2737 (if (looking-at "not.") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2738 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2739 (setq not-match t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2740 (setq regexp |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2741 (concat "^" (buffer-substring 5 (point-max)) "$"))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2742 (setq regexp (concat "^" (buffer-substring 1 (point-max)) "$")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2743 (setq not-match nil)) |
17493 | 2744 ;; Finally - if this resulting regexp matches the group name, |
2745 ;; we add this score file to the list of score files | |
2746 ;; applicable to this group. | |
2747 (when (or (and not-match | |
41494
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
41059
diff
changeset
|
2748 (ignore-errors |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2749 (not (string-match regexp group-trans)))) |
41494
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
41059
diff
changeset
|
2750 (and (not not-match) |
933ab100fb4a
2001-11-25 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
41059
diff
changeset
|
2751 (ignore-errors (string-match regexp group-trans)))) |
17493 | 2752 (push (car sfiles) ofiles))) |
2753 (setq sfiles (cdr sfiles))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2754 (gnus-kill-buffer (current-buffer)) |
17493 | 2755 ;; Slight kludge here - the last score file returned should be |
2756 ;; the local score file, whether it exists or not. This is so | |
2757 ;; that any score commands the user enters will go to the right | |
2758 ;; file, and not end up in some global score file. | |
2759 (let ((localscore (gnus-score-file-name group))) | |
2760 (setq ofiles (cons localscore (delete localscore ofiles)))) | |
2761 (gnus-sort-score-files (nreverse ofiles))))) | |
2762 | |
2763 (defun gnus-score-find-single (group) | |
2764 "Return list containing the score file for GROUP." | |
2765 (list (or gnus-newsgroup-adaptive-score-file | |
2766 (gnus-score-file-name group gnus-adaptive-file-suffix)) | |
2767 (gnus-score-file-name group))) | |
2768 | |
2769 (defun gnus-score-find-hierarchical (group) | |
2770 "Return list of score files for GROUP. | |
2771 This includes the score file for the group and all its parents." | |
2772 (let* ((prefix (gnus-group-real-prefix group)) | |
2773 (all (list nil)) | |
2774 (group (gnus-group-real-name group)) | |
2775 (start 0)) | |
2776 (while (string-match "\\." group (1+ start)) | |
2777 (setq start (match-beginning 0)) | |
2778 (push (substring group 0 start) all)) | |
2779 (push group all) | |
2780 (setq all | |
2781 (nconc | |
2782 (mapcar (lambda (group) | |
2783 (gnus-score-file-name group gnus-adaptive-file-suffix)) | |
2784 (setq all (nreverse all))) | |
2785 (mapcar 'gnus-score-file-name all))) | |
2786 (if (equal prefix "") | |
2787 all | |
2788 (mapcar | |
2789 (lambda (file) | |
2790 (nnheader-translate-file-chars | |
2791 (concat (file-name-directory file) prefix | |
2792 (file-name-nondirectory file)))) | |
2793 all)))) | |
2794 | |
2795 (defun gnus-score-file-rank (file) | |
2796 "Return a number that says how specific score FILE is. | |
2797 Destroys the current buffer." | |
2798 (if (member file gnus-internal-global-score-files) | |
2799 0 | |
2800 (when (string-match | |
2801 (concat "^" (regexp-quote | |
2802 (expand-file-name | |
2803 (file-name-as-directory gnus-kill-files-directory)))) | |
2804 file) | |
2805 (setq file (substring file (match-end 0)))) | |
2806 (insert file) | |
2807 (goto-char (point-min)) | |
2808 (let ((beg (point)) | |
2809 elems) | |
2810 (while (re-search-forward "[./]" nil t) | |
2811 (push (buffer-substring beg (1- (point))) | |
2812 elems)) | |
2813 (erase-buffer) | |
2814 (setq elems (delete "all" elems)) | |
2815 (length elems)))) | |
2816 | |
2817 (defun gnus-sort-score-files (files) | |
2818 "Sort FILES so that the most general files come first." | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2819 (with-temp-buffer |
17493 | 2820 (let ((alist |
2821 (mapcar | |
2822 (lambda (file) | |
2823 (cons (inline (gnus-score-file-rank file)) file)) | |
2824 files))) | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78486
diff
changeset
|
2825 (mapcar 'cdr (sort alist 'car-less-than-car))))) |
17493 | 2826 |
2827 (defun gnus-score-find-alist (group) | |
2828 "Return list of score files for GROUP. | |
41059
70987a4f43c8
Fixed some doc strings to properly quote symbols.
Sam Steingold <sds@gnu.org>
parents:
35978
diff
changeset
|
2829 The list is determined from the variable `gnus-score-file-alist'." |
17493 | 2830 (let ((alist gnus-score-file-multiple-match-alist) |
2831 score-files) | |
2832 ;; if this group has been seen before, return the cached entry | |
2833 (if (setq score-files (assoc group gnus-score-file-alist-cache)) | |
2834 (cdr score-files) ;ensures caching groups with no matches | |
2835 ;; handle the multiple match alist | |
2836 (while alist | |
2837 (when (string-match (caar alist) group) | |
2838 (setq score-files | |
2839 (nconc score-files (copy-sequence (cdar alist))))) | |
2840 (setq alist (cdr alist))) | |
2841 (setq alist gnus-score-file-single-match-alist) | |
2842 ;; handle the single match alist | |
2843 (while alist | |
2844 (when (string-match (caar alist) group) | |
2845 ;; progn used just in case ("regexp") has no files | |
2846 ;; and score-files is still nil. -sj | |
2847 ;; this can be construed as a "stop searching here" feature :> | |
2848 ;; and used to simplify regexps in the single-alist | |
2849 (setq score-files | |
2850 (nconc score-files (copy-sequence (cdar alist)))) | |
2851 (setq alist nil)) | |
2852 (setq alist (cdr alist))) | |
2853 ;; cache the score files | |
2854 (push (cons group score-files) gnus-score-file-alist-cache) | |
2855 score-files))) | |
2856 | |
2857 (defun gnus-all-score-files (&optional group) | |
2858 "Return a list of all score files for the current group." | |
2859 (let ((funcs gnus-score-find-score-files-function) | |
2860 (group (or group gnus-newsgroup-name)) | |
2861 score-files) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2862 (when group |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2863 ;; Make sure funcs is a list. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2864 (and funcs |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2865 (not (listp funcs)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2866 (setq funcs (list funcs))) |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2867 (when gnus-score-use-all-scores |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2868 ;; Get the initial score files for this group. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2869 (when funcs |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2870 (setq score-files (nreverse (gnus-score-find-alist group)))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2871 ;; Add any home adapt files. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2872 (let ((home (gnus-home-score-file group t))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2873 (when home |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2874 (push home score-files) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2875 (setq gnus-newsgroup-adaptive-score-file home))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2876 ;; Check whether there is a `adapt-file' group parameter. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2877 (let ((param-file (gnus-group-find-parameter group 'adapt-file))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2878 (when param-file |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2879 (push param-file score-files) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2880 (setq gnus-newsgroup-adaptive-score-file param-file)))) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2881 ;; Go through all the functions for finding score files (or actual |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2882 ;; scores) and add them to a list. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2883 (while funcs |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2884 (when (functionp (car funcs)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2885 (setq score-files |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2886 (append score-files |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2887 (nreverse (funcall (car funcs) group))))) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2888 (setq funcs (cdr funcs))) |
33319
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2889 (when gnus-score-use-all-scores |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2890 ;; Add any home score files. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2891 (let ((home (gnus-home-score-file group))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2892 (when home |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2893 (push home score-files))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2894 ;; Check whether there is a `score-file' group parameter. |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2895 (let ((param-file (gnus-group-find-parameter group 'score-file))) |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2896 (when param-file |
b398f6832863
(gnus-score-load-file): Use expand-file-name.
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
2897 (push param-file score-files)))) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2898 ;; Expand all files names. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2899 (let ((files score-files)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2900 (while files |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2901 (when (stringp (car files)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2902 (setcar files (expand-file-name |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2903 (car files) gnus-kill-files-directory))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2904 (pop files))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2905 (setq score-files (nreverse score-files)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2906 ;; Remove any duplicate score files. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2907 (while (and score-files |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2908 (member (car score-files) (cdr score-files))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2909 (pop score-files)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2910 (let ((files score-files)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2911 (while (cdr files) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2912 (if (member (cadr files) (cddr files)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2913 (setcdr files (cddr files)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2914 (pop files)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2915 ;; Do the scoring if there are any score files for this group. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2916 score-files))) |
17493 | 2917 |
2918 (defun gnus-possibly-score-headers (&optional trace) | |
2919 "Do scoring if scoring is required." | |
2920 (let ((score-files (gnus-all-score-files))) | |
2921 (when score-files | |
2922 (gnus-score-headers score-files trace)))) | |
2923 | |
2924 (defun gnus-score-file-name (newsgroup &optional suffix) | |
2925 "Return the name of a score file for NEWSGROUP." | |
2926 (let ((suffix (or suffix gnus-score-file-suffix))) | |
2927 (nnheader-translate-file-chars | |
2928 (cond | |
2929 ((or (null newsgroup) | |
2930 (string-equal newsgroup "")) | |
2931 ;; The global score file is placed at top of the directory. | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2932 (expand-file-name suffix gnus-kill-files-directory)) |
17493 | 2933 ((gnus-use-long-file-name 'not-score) |
2934 ;; Append ".SCORE" to newsgroup name. | |
2935 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup) | |
2936 "." suffix) | |
2937 gnus-kill-files-directory)) | |
2938 (t | |
2939 ;; Place "SCORE" under the hierarchical directory. | |
2940 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup) | |
2941 "/" suffix) | |
2942 gnus-kill-files-directory)))))) | |
2943 | |
2944 (defun gnus-score-search-global-directories (files) | |
2945 "Scan all global score directories for score files." | |
2946 ;; Set the variable `gnus-internal-global-score-files' to all | |
2947 ;; available global score files. | |
2948 (interactive (list gnus-global-score-files)) | |
2949 (let (out) | |
2950 (while files | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2951 ;; #### /$ Unix-specific? |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2952 (if (file-directory-p (car files)) |
17493 | 2953 (setq out (nconc (directory-files |
2954 (car files) t | |
2955 (concat (gnus-score-file-regexp) "$")))) | |
2956 (push (car files) out)) | |
2957 (setq files (cdr files))) | |
2958 (setq gnus-internal-global-score-files out))) | |
2959 | |
2960 (defun gnus-score-default-fold-toggle () | |
2961 "Toggle folding for new score file entries." | |
2962 (interactive) | |
2963 (setq gnus-score-default-fold (not gnus-score-default-fold)) | |
2964 (if gnus-score-default-fold | |
2965 (gnus-message 1 "New score file entries will be case insensitive.") | |
2966 (gnus-message 1 "New score file entries will be case sensitive."))) | |
2967 | |
2968 ;;; Home score file. | |
2969 | |
2970 (defun gnus-home-score-file (group &optional adapt) | |
2971 "Return the home score file for GROUP. | |
2972 If ADAPT, return the home adaptive file instead." | |
2973 (let ((list (if adapt gnus-home-adapt-file gnus-home-score-file)) | |
2974 elem found) | |
2975 ;; Make sure we have a list. | |
2976 (unless (listp list) | |
2977 (setq list (list list))) | |
2978 ;; Go through the list and look for matches. | |
2979 (while (and (not found) | |
2980 (setq elem (pop list))) | |
2981 (setq found | |
2982 (cond | |
2983 ;; Simple string. | |
2984 ((stringp elem) | |
2985 elem) | |
2986 ;; Function. | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2987 ((functionp elem) |
17493 | 2988 (funcall elem group)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2989 ;; Regexp-file cons. |
17493 | 2990 ((consp elem) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
2991 (when (string-match (gnus-globalify-regexp (car elem)) group) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2992 (replace-match (cadr elem) t nil group)))))) |
17493 | 2993 (when found |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2994 (setq found (nnheader-translate-file-chars found)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2995 (if (file-name-absolute-p found) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2996 found |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
2997 (nnheader-concat gnus-kill-files-directory found))))) |
17493 | 2998 |
2999 (defun gnus-hierarchial-home-score-file (group) | |
3000 "Return the score file of the top-level hierarchy of GROUP." | |
3001 (if (string-match "^[^.]+\\." group) | |
3002 (concat (match-string 0 group) gnus-score-file-suffix) | |
3003 ;; Group name without any dots. | |
3004 (concat group (if (gnus-use-long-file-name 'not-score) "." "/") | |
3005 gnus-score-file-suffix))) | |
3006 | |
3007 (defun gnus-hierarchial-home-adapt-file (group) | |
3008 "Return the adapt file of the top-level hierarchy of GROUP." | |
3009 (if (string-match "^[^.]+\\." group) | |
3010 (concat (match-string 0 group) gnus-adaptive-file-suffix) | |
3011 ;; Group name without any dots. | |
3012 (concat group (if (gnus-use-long-file-name 'not-score) "." "/") | |
3013 gnus-adaptive-file-suffix))) | |
3014 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3015 (defun gnus-current-home-score-file (group) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3016 "Return the \"current\" regular score file." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3017 (car (nreverse (gnus-score-find-alist group)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3018 |
17493 | 3019 ;;; |
3020 ;;; Score decays | |
3021 ;;; | |
3022 | |
3023 (defun gnus-decay-score (score) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
3024 "Decay SCORE according to `gnus-score-decay-constant' and `gnus-score-decay-scale'." |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
3025 (let ((n (- score |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
3026 (* (if (< score 0) -1 1) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
3027 (min (abs score) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
3028 (max gnus-score-decay-constant |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
3029 (* (abs score) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
3030 gnus-score-decay-scale))))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
3031 (if (and (featurep 'xemacs) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
3032 ;; XEmacs' floor can handle only the floating point |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
3033 ;; number below the half of the maximum integer. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
3034 (> (abs n) (lsh -1 -2))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
3035 (string-to-number |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
3036 (car (split-string (number-to-string n) "\\."))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
3037 (floor n)))) |
17493 | 3038 |
3039 (defun gnus-decay-scores (alist day) | |
3040 "Decay non-permanent scores in ALIST." | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
3041 (let ((times (- (time-to-days (current-time)) day)) |
17493 | 3042 kill entry updated score n) |
3043 (unless (zerop times) ;Done decays today already? | |
3044 (while (setq entry (pop alist)) | |
3045 (when (stringp (car entry)) | |
3046 (setq entry (cdr entry)) | |
3047 (while (setq kill (pop entry)) | |
3048 (when (nth 2 kill) | |
3049 (setq updated t) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
3050 (setq score (or (nth 1 kill) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
3051 gnus-score-interactive-default-score) |
17493 | 3052 n times) |
3053 (while (natnump (decf n)) | |
3054 (setq score (funcall gnus-decay-score-function score))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
3055 (setcdr kill (cons score |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19521
diff
changeset
|
3056 (cdr (cdr kill))))))))) |
17493 | 3057 ;; Return whether this score file needs to be saved. By Je-haysuss! |
3058 updated)) | |
3059 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3060 (defun gnus-score-regexp-bad-p (regexp) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3061 "Test whether REGEXP is safe for Gnus scoring. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3062 A regexp is unsafe if it matches newline or a buffer boundary. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3063 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3064 If the regexp is good, return nil. If the regexp is bad, return a |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3065 cons cell (SYM . STRING), where the symbol SYM is `new' or `bad'. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3066 In the `new' case, the string is a safe replacement for REGEXP. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3067 In the `bad' case, the string is a unsafe subexpression of REGEXP, |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3068 and we do not have a simple replacement to suggest. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3069 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
54491
diff
changeset
|
3070 See Info node `(gnus)Scoring Tips' for examples of good regular expressions." |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3071 (let (case-fold-search) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3072 (and |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3073 ;; First, try a relatively fast necessary condition. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3074 ;; Notice ranges (like [^:] or [\t-\r]), \s>, \Sw, \W, \', \`: |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3075 (string-match "\n\\|\\\\[SsW`']\\|\\[\\^\\|[\0-\n]-" regexp) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3076 ;; Now break the regexp into tokens, and check each: |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3077 (let ((tail regexp) ; remaining regexp to check |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3078 tok ; current token |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3079 bad ; nil, or bad subexpression |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3080 new ; nil, or replacement regexp so far |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3081 end) ; length of current token |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3082 (while (and (not bad) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3083 (string-match |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3084 "\\`\\(\\\\[sS]?.\\|\\[\\^?]?[^]]*]\\|[^\\]\\)" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3085 tail)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3086 (setq end (match-end 0) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3087 tok (substring tail 0 end) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3088 tail (substring tail end)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3089 (if;; Is token `bad' (matching newline or buffer ends)? |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3090 (or (member tok '("\n" "\\W" "\\`" "\\'")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3091 ;; This next handles "[...]", "\\s.", and "\\S.": |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3092 (and (> end 2) (string-match tok "\n"))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3093 (let ((newtok |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3094 ;; Try to suggest a replacement for tok ... |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3095 (cond ((string-equal tok "\\`") "^") ; or "\\(^\\)" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3096 ((string-equal tok "\\'") "$") ; or "\\($\\)" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3097 ((string-match "\\[\\^" tok) ; very common |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3098 (concat (substring tok 0 -1) "\n]"))))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3099 (if newtok |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3100 (setq new |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3101 (concat |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3102 (or new |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3103 ;; good prefix so far: |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3104 (substring regexp 0 (- (+ (length tail) end)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3105 newtok)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3106 ;; No replacement idea, so give up: |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3107 (setq bad tok))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3108 ;; tok is good, may need to extend new |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3109 (and new (setq new (concat new tok))))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3110 ;; Now return a value: |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3111 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3112 (bad (cons 'bad bad)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3113 (new (cons 'new new)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
3114 (t nil)))))) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23362
diff
changeset
|
3115 |
17493 | 3116 (provide 'gnus-score) |
3117 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93386
diff
changeset
|
3118 ;; arch-tag: d3922589-764d-46ae-9954-9330fd192634 |
17493 | 3119 ;;; gnus-score.el ends here |