0baed3b75c8356424a847dbad85385dd8cf92dde
[gnus] / lisp / gnus-score.el
1 ;;; gnus-score.el --- scoring code for Gnus
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000
3 ;;        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 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Commentary:
27
28 ;;; Code:
29
30 (eval-when-compile (require 'cl))
31
32 (require 'gnus)
33 (require 'gnus-sum)
34 (require 'gnus-range)
35 (require 'message)
36 (require 'score-mode)
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 (which see)."
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 (which see)."
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   "*In 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   :group 'gnus-score-decay
150   :type 'boolean)
151
152 (defcustom gnus-decay-score-function 'gnus-decay-score
153   "*Function called to decay a score.
154 It is called with one parameter -- the score to be decayed."
155   :group 'gnus-score-decay
156   :type '(radio (function-item gnus-decay-score)
157                 (function :tag "Other")))
158
159 (defcustom gnus-score-decay-constant 3
160   "*Decay all \"small\" scores with this amount."
161   :group 'gnus-score-decay
162   :type 'integer)
163
164 (defcustom gnus-score-decay-scale .05
165   "*Decay all \"big\" scores with this factor."
166   :group 'gnus-score-decay
167   :type 'number)
168
169 (defcustom gnus-home-score-file nil
170   "Variable to control where interactive score entries are to go.
171 It can be:
172
173  * A string
174    This file file will be used as the home score file.
175
176  * A function
177    The result of this function will be used as the home score file.
178    The function will be passed the name of the group as its
179    parameter.
180
181  * A list
182    The elements in this list can be:
183
184    * `(regexp file-name ...)'
185      If the `regexp' matches the group name, the first `file-name' will
186      will be used as the home score file.  (Multiple filenames are
187      allowed so that one may use gnus-score-file-single-match-alist to
188      set this variable.)
189
190    * A function.
191      If the function returns non-nil, the result will be used
192      as the home score file.  The function will be passed the
193      name of the group as its parameter.
194
195    * A string.  Use the string as the home score file.
196
197    The list will be traversed from the beginning towards the end looking
198    for matches."
199   :group 'gnus-score-files
200   :type '(choice string
201                  (repeat (choice string
202                                  (cons regexp (repeat file))
203                                  (function :value fun)))
204                  (function-item gnus-hierarchial-home-score-file)
205                  (function-item gnus-current-home-score-file)
206                  (function :value fun)))
207
208 (defcustom gnus-home-adapt-file nil
209   "Variable to control where new adaptive score entries are to go.
210 This variable allows the same syntax as `gnus-home-score-file'."
211   :group 'gnus-score-adapt
212   :group 'gnus-score-files
213   :type '(choice string
214                  (repeat (choice string
215                                  (cons regexp (repeat file))
216                                  (function :value fun)))
217                  (function :value fun)))
218
219 (defcustom gnus-default-adaptive-score-alist
220   '((gnus-kill-file-mark)
221     (gnus-unread-mark)
222     (gnus-read-mark (from 3) (subject 30))
223     (gnus-catchup-mark (subject -10))
224     (gnus-killed-mark (from -1) (subject -20))
225     (gnus-del-mark (from -2) (subject -15)))
226   "*Alist of marks and scores."
227   :group 'gnus-score-adapt
228   :type '(repeat (cons (symbol :tag "Mark")
229                        (repeat (list (choice :tag "Header"
230                                              (const from)
231                                              (const subject)
232                                              (symbol :tag "other"))
233                                      (integer :tag "Score"))))))
234
235 (defcustom gnus-ignored-adaptive-words nil
236   "List of words to be ignored when doing adaptive word scoring."
237   :group 'gnus-score-adapt
238   :type '(repeat string))
239
240 (defcustom gnus-default-ignored-adaptive-words
241   '("a" "i" "the" "to" "of" "and" "in" "is" "it" "for" "that" "if" "you"
242     "this" "be" "on" "with" "not" "have" "are" "or" "as" "from" "can"
243     "but" "by" "at" "an" "will" "no" "all" "was" "do" "there" "my" "one"
244     "so" "we" "they" "what" "would" "any" "which" "about" "get" "your"
245     "use" "some" "me" "then" "name" "like" "out" "when" "up" "time"
246     "other" "more" "only" "just" "end" "also" "know" "how" "new" "should"
247     "been" "than" "them" "he" "who" "make" "may" "people" "these" "now"
248     "their" "here" "into" "first" "could" "way" "had" "see" "work" "well"
249     "were" "two" "very" "where" "while" "us" "because" "good" "same"
250     "even" "much" "most" "many" "such" "long" "his" "over" "last" "since"
251     "right" "before" "our" "without" "too" "those" "why" "must" "part"
252     "being" "current" "back" "still" "go" "point" "value" "each" "did"
253     "both" "true" "off" "say" "another" "state" "might" "under" "start"
254     "try" "re")
255   "*Default list of words to be ignored when doing adaptive word scoring."
256   :group 'gnus-score-adapt
257   :type '(repeat string))
258
259 (defcustom gnus-default-adaptive-word-score-alist
260   `((,gnus-read-mark . 30)
261     (,gnus-catchup-mark . -10)
262     (,gnus-killed-mark . -20)
263     (,gnus-del-mark . -15))
264   "*Alist of marks and scores."
265   :group 'gnus-score-adapt
266   :type '(repeat (cons (character :tag "Mark")
267                        (integer :tag "Score"))))
268
269 (defcustom gnus-adaptive-word-minimum nil
270   "If a number, this is the minimum score value that can be assigned to a word."
271   :group 'gnus-score-adapt
272   :type '(choice (const nil) integer))
273
274 (defcustom gnus-adaptive-word-no-group-words nil
275   "If t, don't adaptively score words included in the group name."
276   :group 'gnus-score-adapt
277   :type 'boolean)
278
279 (defcustom gnus-score-mimic-keymap nil
280   "*Have the score entry functions pretend that they are a keymap."
281   :group 'gnus-score-default
282   :type 'boolean)
283
284 (defcustom gnus-score-exact-adapt-limit 10
285   "*Number that says how long a match has to be before using substring matching.
286 When doing adaptive scoring, one normally uses fuzzy or substring
287 matching.  However, if the header one matches is short, the possibility
288 for false positives is great, so if the length of the match is less
289 than this variable, exact matching will be used.
290
291 If this variable is nil, exact matching will always be used."
292   :group 'gnus-score-adapt
293   :type '(choice (const nil) integer))
294
295 (defcustom gnus-score-uncacheable-files "ADAPT$"
296   "All score files that match this regexp will not be cached."
297   :group 'gnus-score-adapt
298   :group 'gnus-score-files
299   :type 'regexp)
300
301 (defcustom gnus-score-default-header nil
302   "Default header when entering new scores.
303
304 Should be one of the following symbols.
305
306  a: from
307  s: subject
308  b: body
309  h: head
310  i: message-id
311  t: references
312  x: xref
313  e: `extra' (non-standard overview)
314  l: lines
315  d: date
316  f: followup
317
318 If nil, the user will be asked for a header."
319   :group 'gnus-score-default
320   :type '(choice (const :tag "from" a)
321                  (const :tag "subject" s)
322                  (const :tag "body" b)
323                  (const :tag "head" h)
324                  (const :tag "message-id" i)
325                  (const :tag "references" t)
326                  (const :tag "xref" x)
327                  (const :tag "extra" e)
328                  (const :tag "lines" l)
329                  (const :tag "date" d)
330                  (const :tag "followup" f)
331                  (const :tag "ask" nil)))
332
333 (defcustom gnus-score-default-type nil
334   "Default match type when entering new scores.
335
336 Should be one of the following symbols.
337
338  s: substring
339  e: exact string
340  f: fuzzy string
341  r: regexp string
342  b: before date
343  a: after date
344  n: this date
345  <: less than number
346  >: greater than number
347  =: equal to number
348
349 If nil, the user will be asked for a match type."
350   :group 'gnus-score-default
351   :type '(choice (const :tag "substring" s)
352                  (const :tag "exact string" e)
353                  (const :tag "fuzzy string" f)
354                  (const :tag "regexp string" r)
355                  (const :tag "before date" b)
356                  (const :tag "after date" a)
357                  (const :tag "this date" n)
358                  (const :tag "less than number" <)
359                  (const :tag "greater than number" >)
360                  (const :tag "equal than number" =)
361                  (const :tag "ask" nil)))
362
363 (defcustom gnus-score-default-fold nil
364   "Use case folding for new score file entries iff not nil."
365   :group 'gnus-score-default
366   :type 'boolean)
367
368 (defcustom gnus-score-default-duration nil
369   "Default duration of effect when entering new scores.
370
371 Should be one of the following symbols.
372
373  t: temporary
374  p: permanent
375  i: immediate
376
377 If nil, the user will be asked for a duration."
378   :group 'gnus-score-default
379   :type '(choice (const :tag "temporary" t)
380                  (const :tag "permanent" p)
381                  (const :tag "immediate" i)
382                  (const :tag "ask" nil)))
383
384 (defcustom gnus-score-after-write-file-function nil
385   "Function called with the name of the score file just written to disk."
386   :group 'gnus-score-files
387   :type 'function)
388
389 (defcustom gnus-score-thread-simplify nil
390   "If non-nil, subjects will simplified as in threading."
391   :group 'gnus-score-various
392   :type 'boolean)
393
394 \f
395
396 ;; Internal variables.
397
398 (defvar gnus-score-use-all-scores t
399   "If nil, only `gnus-score-find-score-files-function' is used.")
400
401 (defvar gnus-adaptive-word-syntax-table
402   (let ((table (copy-syntax-table (standard-syntax-table)))
403         (numbers '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9)))
404     (while numbers
405       (modify-syntax-entry (pop numbers) " " table))
406     (modify-syntax-entry ?' "w" table)
407     table)
408   "Syntax table used when doing adaptive word scoring.")
409
410 (defvar gnus-scores-exclude-files nil)
411 (defvar gnus-internal-global-score-files nil)
412 (defvar gnus-score-file-list nil)
413
414 (defvar gnus-short-name-score-file-cache nil)
415
416 (defvar gnus-score-help-winconf nil)
417 (defvar gnus-adaptive-score-alist gnus-default-adaptive-score-alist)
418 (defvar gnus-adaptive-word-score-alist gnus-default-adaptive-word-score-alist)
419 (defvar gnus-score-trace nil)
420 (defvar gnus-score-edit-buffer nil)
421
422 (defvar gnus-score-alist nil
423   "Alist containing score information.
424 The keys can be symbols or strings.  The following symbols are defined.
425
426 touched: If this alist has been modified.
427 mark:    Automatically mark articles below this.
428 expunge: Automatically expunge articles below this.
429 files:   List of other score files to load when loading this one.
430 eval:    Sexp to be evaluated when the score file is loaded.
431
432 String entries have the form (HEADER (MATCH TYPE SCORE DATE) ...)
433 where HEADER is the header being scored, MATCH is the string we are
434 looking for, TYPE is a flag indicating whether it should use regexp or
435 substring matching, SCORE is the score to add and DATE is the date
436 of the last successful match.")
437
438 (defvar gnus-score-cache nil)
439 (defvar gnus-scores-articles nil)
440 (defvar gnus-score-index nil)
441
442
443 (defconst gnus-header-index
444   ;; Name to index alist.
445   '(("number" 0 gnus-score-integer)
446     ("subject" 1 gnus-score-string)
447     ("from" 2 gnus-score-string)
448     ("date" 3 gnus-score-date)
449     ("message-id" 4 gnus-score-string)
450     ("references" 5 gnus-score-string)
451     ("chars" 6 gnus-score-integer)
452     ("lines" 7 gnus-score-integer)
453     ("xref" 8 gnus-score-string)
454     ("extra" 9 gnus-score-string)
455     ("head" -1 gnus-score-body)
456     ("body" -1 gnus-score-body)
457     ("all" -1 gnus-score-body)
458     ("followup" 2 gnus-score-followup)
459     ("thread" 5 gnus-score-thread)))
460
461 ;;; Summary mode score maps.
462
463 (gnus-define-keys (gnus-summary-score-map "V" gnus-summary-mode-map)
464   "s" gnus-summary-set-score
465   "S" gnus-summary-current-score
466   "c" gnus-score-change-score-file
467   "C" gnus-score-customize
468   "m" gnus-score-set-mark-below
469   "x" gnus-score-set-expunge-below
470   "R" gnus-summary-rescore
471   "e" gnus-score-edit-current-scores
472   "f" gnus-score-edit-file
473   "F" gnus-score-flush-cache
474   "t" gnus-score-find-trace
475   "w" gnus-score-find-favourite-words)
476
477 ;; Summary score file commands
478
479 ;; Much modification of the kill (ahem, score) code and lots of the
480 ;; functions are written by Per Abrahamsen <amanda@iesd.auc.dk>.
481
482 (defun gnus-summary-lower-score (&optional score symp)
483   "Make a score entry based on the current article.
484 The user will be prompted for header to score on, match type,
485 permanence, and the string to be used.  The numerical prefix will be
486 used as score."
487   (interactive (gnus-interactive "P\ny"))
488   (gnus-summary-increase-score (- (gnus-score-delta-default score)) symp))
489
490 (defun gnus-score-kill-help-buffer ()
491   (when (get-buffer "*Score Help*")
492     (kill-buffer "*Score Help*")
493     (when gnus-score-help-winconf
494       (set-window-configuration gnus-score-help-winconf))))
495
496 (defun gnus-summary-increase-score (&optional score symp)
497   "Make a score entry based on the current article.
498 The user will be prompted for header to score on, match type,
499 permanence, and the string to be used.  The numerical prefix will be
500 used as score."
501   (interactive (gnus-interactive "P\ny"))
502   (let* ((nscore (gnus-score-delta-default score))
503          (prefix (if (< nscore 0) ?L ?I))
504          (increase (> nscore 0))
505          (char-to-header
506           '((?a "from" nil nil string)
507             (?s "subject" nil nil string)
508             (?b "body" "" nil body-string)
509             (?h "head" "" nil body-string)
510             (?i "message-id" nil nil string)
511             (?r "references" "message-id" nil string)
512             (?x "xref" nil nil string)
513             (?e "extra" nil nil string)
514             (?l "lines" nil nil number)
515             (?d "date" nil nil date)
516             (?f "followup" nil nil string)
517             (?t "thread" "message-id" nil string)))
518          (char-to-type
519           '((?s s "substring" string)
520             (?e e "exact string" string)
521             (?f f "fuzzy string" string)
522             (?r r "regexp string" string)
523             (?z s "substring" body-string)
524             (?p r "regexp string" body-string)
525             (?b before "before date" date)
526             (?a after "after date" date)
527             (?n at "this date" date)
528             (?< < "less than number" number)
529             (?> > "greater than number" number)
530             (?= = "equal to number" number)))
531          (current-score-file gnus-current-score-file)
532          (char-to-perm
533           (list (list ?t (current-time-string) "temporary")
534                 '(?p perm "permanent") '(?i now "immediate")))
535          (mimic gnus-score-mimic-keymap)
536          (hchar (and gnus-score-default-header
537                      (aref (symbol-name gnus-score-default-header) 0)))
538          (tchar (and gnus-score-default-type
539                      (aref (symbol-name gnus-score-default-type) 0)))
540          (pchar (and gnus-score-default-duration
541                      (aref (symbol-name gnus-score-default-duration) 0)))
542          entry temporary type match extra)
543
544     (unwind-protect
545         (progn
546
547           ;; First we read the header to score.
548           (while (not hchar)
549             (if mimic
550                 (progn
551                   (sit-for 1)
552                   (message "%c-" prefix))
553               (message "%s header (%s?): " (if increase "Increase" "Lower")
554                        (mapconcat (lambda (s) (char-to-string (car s)))
555                                   char-to-header "")))
556             (setq hchar (read-char))
557             (when (or (= hchar ??) (= hchar ?\C-h))
558               (setq hchar nil)
559               (gnus-score-insert-help "Match on header" char-to-header 1)))
560
561           (gnus-score-kill-help-buffer)
562           (unless (setq entry (assq (downcase hchar) char-to-header))
563             (if mimic (error "%c %c" prefix hchar)
564               (error "Invalid header type")))
565
566           (when (/= (downcase hchar) hchar)
567             ;; This was a majuscule, so we end reading and set the defaults.
568             (if mimic (message "%c %c" prefix hchar) (message ""))
569             (setq tchar (or tchar ?s)
570                   pchar (or pchar ?t)))
571
572           (let ((legal-types
573                  (delq nil
574                        (mapcar (lambda (s)
575                                  (if (eq (nth 4 entry)
576                                          (nth 3 s))
577                                      s nil))
578                                char-to-type))))
579             ;; We continue reading - the type.
580             (while (not tchar)
581               (if mimic
582                   (progn
583                     (sit-for 1) (message "%c %c-" prefix hchar))
584                 (message "%s header '%s' with match type (%s?): "
585                          (if increase "Increase" "Lower")
586                          (nth 1 entry)
587                          (mapconcat (lambda (s) (char-to-string (car s)))
588                                     legal-types "")))
589               (setq tchar (read-char))
590               (when (or (= tchar ??) (= tchar ?\C-h))
591                 (setq tchar nil)
592                 (gnus-score-insert-help "Match type" legal-types 2)))
593
594             (gnus-score-kill-help-buffer)
595             (unless (setq type (nth 1 (assq (downcase tchar) legal-types)))
596               (if mimic (error "%c %c" prefix hchar)
597                 (error "Invalid match type"))))
598
599           (when (/= (downcase tchar) tchar)
600             ;; It was a majuscule, so we end reading and use the default.
601             (if mimic (message "%c %c %c" prefix hchar tchar)
602               (message ""))
603             (setq pchar (or pchar ?t)))
604
605           ;; We continue reading.
606           (while (not pchar)
607             (if mimic
608                 (progn
609                   (sit-for 1) (message "%c %c %c-" prefix hchar tchar))
610               (message "%s permanence (%s?): " (if increase "Increase" "Lower")
611                        (mapconcat (lambda (s) (char-to-string (car s)))
612                                   char-to-perm "")))
613             (setq pchar (read-char))
614             (when (or (= pchar ??) (= pchar ?\C-h))
615               (setq pchar nil)
616               (gnus-score-insert-help "Match permanence" char-to-perm 2)))
617
618           (gnus-score-kill-help-buffer)
619           (if mimic (message "%c %c %c" prefix hchar tchar pchar)
620             (message ""))
621           (unless (setq temporary (cadr (assq pchar char-to-perm)))
622             ;; Deal with der(r)ided superannuated paradigms.
623             (when (and (eq (1+ prefix) 77)
624                        (eq (+ hchar 12) 109)
625                        (eq (1- tchar) 113)
626                        (eq (- pchar 4) 111))
627               (error "You rang?"))
628             (if mimic
629                 (error "%c %c %c %c" prefix hchar tchar pchar)
630               (error "Invalid match duration"))))
631       ;; Always kill the score help buffer.
632       (gnus-score-kill-help-buffer))
633
634     ;; If scoring an extra (non-standard overview) header,
635     ;; we must find out which header is in question.
636     (setq extra
637           (and gnus-extra-headers
638                (equal (nth 1 entry) "extra")
639                (intern                  ; need symbol
640                 (gnus-completing-read
641                  (symbol-name (car gnus-extra-headers)) ; default response
642                  "Score extra header:"  ; prompt
643                  (mapcar (lambda (x)    ; completion list
644                            (cons (symbol-name x) x))
645                          gnus-extra-headers)
646                  nil                    ; no completion limit
647                  t))))                  ; require match
648     ;; extra is now nil or a symbol.
649
650     ;; We have all the data, so we enter this score.
651     (setq match (if (string= (nth 2 entry) "") ""
652                   (gnus-summary-header (or (nth 2 entry) (nth 1 entry))
653                                        nil extra)))
654
655     ;; Modify the match, perhaps.
656     (cond
657      ((equal (nth 1 entry) "xref")
658       (when (string-match "^Xref: *" match)
659         (setq match (substring match (match-end 0))))
660       (when (string-match "^[^:]* +" match)
661         (setq match (substring match (match-end 0))))))
662
663     (when (memq type '(r R regexp Regexp))
664       (setq match (regexp-quote match)))
665
666     ;; Change score file to the "all.SCORE" file.
667     (when (eq symp 'a)
668       (save-excursion
669         (set-buffer gnus-summary-buffer)
670         (gnus-score-load-file
671          ;; This is a kludge; yes...
672          (cond
673           ((eq gnus-score-find-score-files-function
674                'gnus-score-find-hierarchical)
675            (gnus-score-file-name ""))
676           ((eq gnus-score-find-score-files-function 'gnus-score-find-single)
677            current-score-file)
678           (t
679            (gnus-score-file-name "all"))))))
680
681     (gnus-summary-score-entry
682      (nth 1 entry)                      ; Header
683      match                              ; Match
684      type                               ; Type
685      (if (eq score 's) nil score)       ; Score
686      (if (eq temporary 'perm)           ; Temp
687          nil
688        temporary)
689      (not (nth 3 entry))                ; Prompt
690      nil                                ; not silent
691      extra)                             ; non-standard overview.
692
693     (when (eq symp 'a)
694       ;; We change the score file back to the previous one.
695       (save-excursion
696         (set-buffer gnus-summary-buffer)
697         (gnus-score-load-file current-score-file)))))
698
699 (defun gnus-score-insert-help (string alist idx)
700   (setq gnus-score-help-winconf (current-window-configuration))
701   (save-excursion
702     (set-buffer (gnus-get-buffer-create "*Score Help*"))
703     (buffer-disable-undo)
704     (delete-windows-on (current-buffer))
705     (erase-buffer)
706     (insert string ":\n\n")
707     (let ((max -1)
708           (list alist)
709           (i 0)
710           n width pad format)
711       ;; find the longest string to display
712       (while list
713         (setq n (length (nth idx (car list))))
714         (unless (> max n)
715           (setq max n))
716         (setq list (cdr list)))
717       (setq max (+ max 4))              ; %c, `:', SPACE, a SPACE at end
718       (setq n (/ (1- (window-width)) max)) ; items per line
719       (setq width (/ (1- (window-width)) n)) ; width of each item
720       ;; insert `n' items, each in a field of width `width'
721       (while alist
722         (if (< i n)
723             ()
724           (setq i 0)
725           (delete-char -1)              ; the `\n' takes a char
726           (insert "\n"))
727         (setq pad (- width 3))
728         (setq format (concat "%c: %-" (int-to-string pad) "s"))
729         (insert (format format (caar alist) (nth idx (car alist))))
730         (setq alist (cdr alist))
731         (setq i (1+ i))))
732     ;; display ourselves in a small window at the bottom
733     (gnus-appt-select-lowest-window)
734     (split-window)
735     (pop-to-buffer "*Score Help*")
736     (let ((window-min-height 1))
737       (shrink-window-if-larger-than-buffer))
738     (select-window (get-buffer-window gnus-summary-buffer t))))
739
740 (defun gnus-summary-header (header &optional no-err extra)
741   ;; Return HEADER for current articles, or error.
742   (let ((article (gnus-summary-article-number))
743         headers)
744     (if article
745         (if (and (setq headers (gnus-summary-article-header article))
746                  (vectorp headers))
747             (if extra                   ; `header' must be "extra"
748                 (or (cdr (assq extra (mail-header-extra headers))) "")
749               (aref headers (nth 1 (assoc header gnus-header-index))))
750           (if no-err
751               nil
752             (error "Pseudo-articles can't be scored")))
753       (if no-err
754           (error "No article on current line")
755         nil))))
756
757 (defun gnus-newsgroup-score-alist ()
758   (or
759    (let ((param-file (gnus-group-find-parameter
760                       gnus-newsgroup-name 'score-file)))
761      (when param-file
762        (gnus-score-load param-file)))
763    (gnus-score-load
764     (gnus-score-file-name gnus-newsgroup-name)))
765   gnus-score-alist)
766
767 (defsubst gnus-score-get (symbol &optional alist)
768   ;; Get SYMBOL's definition in ALIST.
769   (cdr (assoc symbol
770               (or alist
771                   gnus-score-alist
772                   (gnus-newsgroup-score-alist)))))
773
774 (defun gnus-summary-score-entry (header match type score date
775                                         &optional prompt silent extra)
776   "Enter score file entry.
777 HEADER is the header being scored.
778 MATCH is the string we are looking for.
779 TYPE is the match type: substring, regexp, exact, fuzzy.
780 SCORE is the score to add.
781 DATE is the expire date, or nil for no expire, or 'now for immediate expire.
782 If optional argument `PROMPT' is non-nil, allow user to edit match.
783 If optional argument `SILENT' is nil, show effect of score entry.
784 If optional argument `EXTRA' is non-nil, it's a non-standard overview header."
785   ;; Regexp is the default type.
786   (when (eq type t)
787     (setq type 'r))
788   ;; Simplify matches...
789   (cond ((or (eq type 'r) (eq type 's) (eq type nil))
790          (setq match (if match (gnus-simplify-subject-re match) "")))
791         ((eq type 'f)
792          (setq match (gnus-simplify-subject-fuzzy match))))
793   (let ((score (gnus-score-delta-default score))
794         (header (downcase header))
795         new)
796     (set-text-properties 0 (length header) nil header)
797     (when prompt
798       (setq match (read-string
799                    (format "Match %s on %s, %s: "
800                            (cond ((eq date 'now)
801                                   "now")
802                                  ((stringp date)
803                                   "temp")
804                                  (t "permanent"))
805                            header
806                            (if (< score 0) "lower" "raise"))
807                    (if (numberp match)
808                        (int-to-string match)
809                      match))))
810
811     (set-text-properties 0 (length match) nil match)
812
813     ;; If this is an integer comparison, we transform from string to int.
814     (when (eq (nth 2 (assoc header gnus-header-index)) 'gnus-score-integer)
815       (setq match (string-to-int match)))
816
817     (unless (eq date 'now)
818       ;; Add the score entry to the score file.
819       (when (= score gnus-score-interactive-default-score)
820         (setq score nil))
821       (let ((old (gnus-score-get header))
822             elem)
823         (setq new
824               (cond
825                (extra
826                 (list match score
827                       (and date (if (numberp date) date
828                                   (date-to-day date)))
829                       type (symbol-name extra)))
830                (type
831                 (list match score
832                       (and date (if (numberp date) date
833                                   (date-to-day date)))
834                       type))
835                (date (list match score (date-to-day date)))
836                (score (list match score))
837                (t (list match))))
838         ;; We see whether we can collapse some score entries.
839         ;; This isn't quite correct, because there may be more elements
840         ;; later on with the same key that have matching elems...  Hm.
841         (if (and old
842                  (setq elem (assoc match old))
843                  (eq (nth 3 elem) (nth 3 new))
844                  (or (and (numberp (nth 2 elem)) (numberp (nth 2 new)))
845                      (and (not (nth 2 elem)) (not (nth 2 new)))))
846             ;; Yup, we just add this new score to the old elem.
847             (setcar (cdr elem) (+ (or (nth 1 elem)
848                                       gnus-score-interactive-default-score)
849                                   (or (nth 1 new)
850                                       gnus-score-interactive-default-score)))
851           ;; Nope, we have to add a new elem.
852           (gnus-score-set header (if old (cons new old) (list new)) nil t))
853         (gnus-score-set 'touched '(t))))
854
855     ;; Score the current buffer.
856     (unless silent
857       (if (and (>= (nth 1 (assoc header gnus-header-index)) 0)
858                (eq (nth 2 (assoc header gnus-header-index))
859                    'gnus-score-string))
860           (gnus-summary-score-effect header match type score extra)
861         (gnus-summary-rescore)))
862
863     ;; Return the new scoring rule.
864     new))
865
866 (defun gnus-summary-score-effect (header match type score extra)
867   "Simulate the effect of a score file entry.
868 HEADER is the header being scored.
869 MATCH is the string we are looking for.
870 TYPE is the score type.
871 SCORE is the score to add.
872 EXTRA is the possible non-standard header."
873   (interactive (list (completing-read "Header: "
874                                       gnus-header-index
875                                       (lambda (x) (fboundp (nth 2 x)))
876                                       t)
877                      (read-string "Match: ")
878                      (y-or-n-p "Use regexp match? ")
879                      (prefix-numeric-value current-prefix-arg)))
880   (save-excursion
881     (unless (and (stringp match) (> (length match) 0))
882       (error "No match"))
883     (goto-char (point-min))
884     (let ((regexp (cond ((eq type 'f)
885                          (gnus-simplify-subject-fuzzy match))
886                         ((eq type 'r)
887                          match)
888                         ((eq type 'e)
889                          (concat "\\`" (regexp-quote match) "\\'"))
890                         (t
891                          (regexp-quote match)))))
892       (while (not (eobp))
893         (let ((content (gnus-summary-header header 'noerr extra))
894               (case-fold-search t))
895           (and content
896                (when (if (eq type 'f)
897                          (string-equal (gnus-simplify-subject-fuzzy content)
898                                        regexp)
899                        (string-match regexp content))
900                  (gnus-summary-raise-score score))))
901         (beginning-of-line 2))))
902   (gnus-set-mode-line 'summary))
903
904 (defun gnus-summary-score-crossposting (score date)
905   ;; Enter score file entry for current crossposting.
906   ;; SCORE is the score to add.
907   ;; DATE is the expire date.
908   (let ((xref (gnus-summary-header "xref"))
909         (start 0)
910         group)
911     (unless xref
912       (error "This article is not crossposted"))
913     (while (string-match " \\([^ \t]+\\):" xref start)
914       (setq start (match-end 0))
915       (when (not (string=
916                   (setq group
917                         (substring xref (match-beginning 1) (match-end 1)))
918                   gnus-newsgroup-name))
919         (gnus-summary-score-entry
920          "xref" (concat " " group ":") nil score date t)))))
921
922 \f
923 ;;;
924 ;;; Gnus Score Files
925 ;;;
926
927 ;; All score code written by Per Abrahamsen <abraham@iesd.auc.dk>.
928
929 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
930 (defun gnus-score-set-mark-below (score)
931   "Automatically mark articles with score below SCORE as read."
932   (interactive
933    (list (or (and current-prefix-arg (prefix-numeric-value current-prefix-arg))
934              (string-to-int (read-string "Mark below: ")))))
935   (setq score (or score gnus-summary-default-score 0))
936   (gnus-score-set 'mark (list score))
937   (gnus-score-set 'touched '(t))
938   (setq gnus-summary-mark-below score)
939   (gnus-score-update-lines))
940
941 (defun gnus-score-update-lines ()
942   "Update all lines in the summary buffer."
943   (save-excursion
944     (goto-char (point-min))
945     (while (not (eobp))
946       (gnus-summary-update-line)
947       (forward-line 1))))
948
949 (defun gnus-score-update-all-lines ()
950   "Update all lines in the summary buffer, even the hidden ones."
951   (save-excursion
952     (goto-char (point-min))
953     (let (hidden)
954       (while (not (eobp))
955         (when (gnus-summary-show-thread)
956           (push (point) hidden))
957         (gnus-summary-update-line)
958         (forward-line 1))
959       ;; Re-hide the hidden threads.
960       (while hidden
961         (goto-char (pop hidden))
962         (gnus-summary-hide-thread)))))
963
964 (defun gnus-score-set-expunge-below (score)
965   "Automatically expunge articles with score below SCORE."
966   (interactive
967    (list (or (and current-prefix-arg (prefix-numeric-value current-prefix-arg))
968              (string-to-int (read-string "Set expunge below: ")))))
969   (setq score (or score gnus-summary-default-score 0))
970   (gnus-score-set 'expunge (list score))
971   (gnus-score-set 'touched '(t)))
972
973 (defun gnus-score-followup-article (&optional score)
974   "Add SCORE to all followups to the article in the current buffer."
975   (interactive "P")
976   (setq score (gnus-score-delta-default score))
977   (when (gnus-buffer-live-p gnus-summary-buffer)
978     (save-excursion
979       (save-restriction
980         (message-narrow-to-headers)
981         (let ((id (mail-fetch-field "message-id")))
982           (when id
983             (set-buffer gnus-summary-buffer)
984             (gnus-summary-score-entry
985              "references" (concat id "[ \t]*$") 'r
986              score (current-time-string) nil t)))))))
987
988 (defun gnus-score-followup-thread (&optional score)
989   "Add SCORE to all later articles in the thread the current buffer is part of."
990   (interactive "P")
991   (setq score (gnus-score-delta-default score))
992   (when (gnus-buffer-live-p gnus-summary-buffer)
993     (save-excursion
994       (save-restriction
995         (goto-char (point-min))
996         (let ((id (mail-fetch-field "message-id")))
997           (when id
998             (set-buffer gnus-summary-buffer)
999             (gnus-summary-score-entry
1000              "references" id 's
1001              score (current-time-string))))))))
1002
1003 (defun gnus-score-set (symbol value &optional alist warn)
1004   ;; Set SYMBOL to VALUE in ALIST.
1005   (let* ((alist
1006           (or alist
1007               gnus-score-alist
1008               (gnus-newsgroup-score-alist)))
1009          (entry (assoc symbol alist)))
1010     (cond ((gnus-score-get 'read-only alist)
1011            ;; This is a read-only score file, so we do nothing.
1012            (when warn
1013              (gnus-message 4 "Note: read-only score file; entry discarded")))
1014           (entry
1015            (setcdr entry value))
1016           ((null alist)
1017            (error "Empty alist"))
1018           (t
1019            (setcdr alist
1020                    (cons (cons symbol value) (cdr alist)))))))
1021
1022 (defun gnus-summary-raise-score (n)
1023   "Raise the score of the current article by N."
1024   (interactive "p")
1025   (gnus-summary-set-score (+ (gnus-summary-article-score)
1026                              (or n gnus-score-interactive-default-score ))))
1027
1028 (defun gnus-summary-set-score (n)
1029   "Set the score of the current article to N."
1030   (interactive "p")
1031   (save-excursion
1032     (gnus-summary-show-thread)
1033     (let ((buffer-read-only nil))
1034       ;; Set score.
1035       (gnus-summary-update-mark
1036        (if (= n (or gnus-summary-default-score 0)) ?  ;Whitespace
1037          (if (< n (or gnus-summary-default-score 0))
1038              gnus-score-below-mark gnus-score-over-mark))
1039        'score))
1040     (let* ((article (gnus-summary-article-number))
1041            (score (assq article gnus-newsgroup-scored)))
1042       (if score (setcdr score n)
1043         (push (cons article n) gnus-newsgroup-scored)))
1044     (gnus-summary-update-line)))
1045
1046 (defun gnus-summary-current-score ()
1047   "Return the score of the current article."
1048   (interactive)
1049   (gnus-message 1 "%s" (gnus-summary-article-score)))
1050
1051 (defun gnus-score-change-score-file (file)
1052   "Change current score alist."
1053   (interactive
1054    (list (read-file-name "Change to score file: " gnus-kill-files-directory)))
1055   (gnus-score-load-file file)
1056   (gnus-set-mode-line 'summary))
1057
1058 (defvar gnus-score-edit-exit-function)
1059 (defun gnus-score-edit-current-scores (file)
1060   "Edit the current score alist."
1061   (interactive (list gnus-current-score-file))
1062   (if (not gnus-current-score-file)
1063       (error "No current score file")
1064     (let ((winconf (current-window-configuration)))
1065       (when (buffer-name gnus-summary-buffer)
1066         (gnus-score-save))
1067       (gnus-make-directory (file-name-directory file))
1068       (setq gnus-score-edit-buffer (find-file-noselect file))
1069       (gnus-configure-windows 'edit-score)
1070       (gnus-score-mode)
1071       (setq gnus-score-edit-exit-function 'gnus-score-edit-done)
1072       (make-local-variable 'gnus-prev-winconf)
1073       (setq gnus-prev-winconf winconf))
1074     (gnus-message
1075      4 (substitute-command-keys
1076         "\\<gnus-score-mode-map>\\[gnus-score-edit-exit] to save edits"))))
1077
1078 (defun gnus-score-edit-file (file)
1079   "Edit a score file."
1080   (interactive
1081    (list (read-file-name "Edit score file: " gnus-kill-files-directory)))
1082   (gnus-make-directory (file-name-directory file))
1083   (when (buffer-name gnus-summary-buffer)
1084     (gnus-score-save))
1085   (let ((winconf (current-window-configuration)))
1086     (setq gnus-score-edit-buffer (find-file-noselect file))
1087     (gnus-configure-windows 'edit-score)
1088     (gnus-score-mode)
1089     (setq gnus-score-edit-exit-function 'gnus-score-edit-done)
1090     (make-local-variable 'gnus-prev-winconf)
1091     (setq gnus-prev-winconf winconf))
1092   (gnus-message
1093    4 (substitute-command-keys
1094       "\\<gnus-score-mode-map>\\[gnus-score-edit-exit] to save edits")))
1095
1096 (defun gnus-score-load-file (file)
1097   ;; Load score file FILE.  Returns a list a retrieved score-alists.
1098   (let* ((file (expand-file-name
1099                 (or (and (string-match
1100                           (concat "^" (regexp-quote
1101                                        (expand-file-name
1102                                         gnus-kill-files-directory)))
1103                           (expand-file-name file))
1104                          file)
1105                     (concat (file-name-as-directory gnus-kill-files-directory)
1106                             file))))
1107          (cached (assoc file gnus-score-cache))
1108          (global (member file gnus-internal-global-score-files))
1109          lists alist)
1110     (if cached
1111         ;; The score file was already loaded.
1112         (setq alist (cdr cached))
1113       ;; We load the score file.
1114       (setq gnus-score-alist nil)
1115       (setq alist (gnus-score-load-score-alist file))
1116       ;; We add '(touched) to the alist to signify that it hasn't been
1117       ;; touched (yet).
1118       (unless (assq 'touched alist)
1119         (push (list 'touched nil) alist))
1120       ;; If it is a global score file, we make it read-only.
1121       (and global
1122            (not (assq 'read-only alist))
1123            (push (list 'read-only t) alist))
1124       (push (cons file alist) gnus-score-cache))
1125     (let ((a alist)
1126           found)
1127       (while a
1128         ;; Downcase all header names.
1129         (cond
1130          ((stringp (caar a))
1131           (setcar (car a) (downcase (caar a)))
1132           (setq found t))
1133          ;; Advanced scoring.
1134          ((consp (caar a))
1135           (setq found t)))
1136         (pop a))
1137       ;; If there are actual scores in the alist, we add it to the
1138       ;; return value of this function.
1139       (when found
1140         (setq lists (list alist))))
1141     ;; Treat the other possible atoms in the score alist.
1142     (let ((mark (car (gnus-score-get 'mark alist)))
1143           (expunge (car (gnus-score-get 'expunge alist)))
1144           (mark-and-expunge (car (gnus-score-get 'mark-and-expunge alist)))
1145           (files (gnus-score-get 'files alist))
1146           (exclude-files (gnus-score-get 'exclude-files alist))
1147           (orphan (car (gnus-score-get 'orphan alist)))
1148           (adapt (gnus-score-get 'adapt alist))
1149           (thread-mark-and-expunge
1150            (car (gnus-score-get 'thread-mark-and-expunge alist)))
1151           (adapt-file (car (gnus-score-get 'adapt-file alist)))
1152           (local (gnus-score-get 'local alist))
1153           (decay (car (gnus-score-get 'decay alist)))
1154           (eval (car (gnus-score-get 'eval alist))))
1155       ;; Perform possible decays.
1156       (when (and gnus-decay-scores
1157                  (or cached (file-exists-p file))
1158                  (or (not decay)
1159                      (gnus-decay-scores alist decay)))
1160         (gnus-score-set 'touched '(t) alist)
1161         (gnus-score-set 'decay (list (time-to-days (current-time))) alist))
1162       ;; We do not respect eval and files atoms from global score
1163       ;; files.
1164       (when (and files (not global))
1165         (setq lists (apply 'append lists
1166                            (mapcar (lambda (file)
1167                                      (gnus-score-load-file file))
1168                                    (if adapt-file (cons adapt-file files)
1169                                      files)))))
1170       (when (and eval (not global))
1171         (eval eval))
1172       ;; We then expand any exclude-file directives.
1173       (setq gnus-scores-exclude-files
1174             (nconc
1175              (apply
1176               'nconc
1177               (mapcar
1178                (lambda (sfile)
1179                  (list
1180                   (expand-file-name sfile (file-name-directory file))
1181                   (expand-file-name sfile gnus-kill-files-directory)))
1182                exclude-files))
1183              gnus-scores-exclude-files))
1184       (when local
1185         (save-excursion
1186           (set-buffer gnus-summary-buffer)
1187           (while local
1188             (and (consp (car local))
1189                  (symbolp (caar local))
1190                  (progn
1191                    (make-local-variable (caar local))
1192                    (set (caar local) (nth 1 (car local)))))
1193             (setq local (cdr local)))))
1194       (when orphan
1195         (setq gnus-orphan-score orphan))
1196       (setq gnus-adaptive-score-alist
1197             (cond ((equal adapt '(t))
1198                    (setq gnus-newsgroup-adaptive t)
1199                    gnus-default-adaptive-score-alist)
1200                   ((equal adapt '(ignore))
1201                    (setq gnus-newsgroup-adaptive nil))
1202                   ((consp adapt)
1203                    (setq gnus-newsgroup-adaptive t)
1204                    adapt)
1205                   (t
1206                    ;;(setq gnus-newsgroup-adaptive gnus-use-adaptive-scoring)
1207                    gnus-default-adaptive-score-alist)))
1208       (setq gnus-thread-expunge-below
1209             (or thread-mark-and-expunge gnus-thread-expunge-below))
1210       (setq gnus-summary-mark-below
1211             (or mark mark-and-expunge gnus-summary-mark-below))
1212       (setq gnus-summary-expunge-below
1213             (or expunge mark-and-expunge gnus-summary-expunge-below))
1214       (setq gnus-newsgroup-adaptive-score-file
1215             (or adapt-file gnus-newsgroup-adaptive-score-file)))
1216     (setq gnus-current-score-file file)
1217     (setq gnus-score-alist alist)
1218     lists))
1219
1220 (defun gnus-score-load (file)
1221   ;; Load score FILE.
1222   (let ((cache (assoc file gnus-score-cache)))
1223     (if cache
1224         (setq gnus-score-alist (cdr cache))
1225       (setq gnus-score-alist nil)
1226       (gnus-score-load-score-alist file)
1227       (unless gnus-score-alist
1228         (setq gnus-score-alist (copy-alist '((touched nil)))))
1229       (push (cons file gnus-score-alist) gnus-score-cache))))
1230
1231 (defun gnus-score-remove-from-cache (file)
1232   (setq gnus-score-cache
1233         (delq (assoc file gnus-score-cache) gnus-score-cache)))
1234
1235 (defun gnus-score-load-score-alist (file)
1236   "Read score FILE."
1237   (let (alist)
1238     (if (not (file-readable-p file))
1239         ;; Couldn't read file.
1240         (setq gnus-score-alist nil)
1241       ;; Read file.
1242       (with-temp-buffer
1243         (let ((coding-system-for-read score-mode-coding-system))
1244           (insert-file-contents file))
1245         (goto-char (point-min))
1246         ;; Only do the loading if the score file isn't empty.
1247         (when (save-excursion (re-search-forward "[()0-9a-zA-Z]" nil t))
1248           (setq alist
1249                 (condition-case ()
1250                     (read (current-buffer))
1251                   (error
1252                    (gnus-error 3.2 "Problem with score file %s" file))))))
1253       (cond
1254        ((and alist
1255              (atom alist))
1256         ;; Bogus score file.
1257         (error "Invalid syntax with score file %s" file))
1258        ((eq (car alist) 'setq)
1259         ;; This is an old-style score file.
1260         (setq gnus-score-alist (gnus-score-transform-old-to-new alist)))
1261        (t
1262         (setq gnus-score-alist alist)))
1263       ;; Check the syntax of the score file.
1264       (setq gnus-score-alist
1265             (gnus-score-check-syntax gnus-score-alist file)))))
1266
1267 (defun gnus-score-check-syntax (alist file)
1268   "Check the syntax of the score ALIST."
1269   (cond
1270    ((null alist)
1271     nil)
1272    ((not (consp alist))