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