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