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