annotate lisp/gnus/gnus-score.el @ 18:d95e72db5c07 r19-15b92

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