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