2001-07-15 Pavel Jan\e,Bm\e(Bk <Pavel@Janik.cz>
[gnus] / lisp / gnus-cus.el
1 ;;; gnus-cus.el --- customization commands for Gnus
2 ;;
3 ;; Copyright (C) 1996,1999, 2000 Free Software Foundation, Inc.
4
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6 ;; Keywords: news
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
27 ;;; Code:
28
29 (require 'wid-edit)
30 (require 'gnus)
31 (require 'gnus-score)
32 (require 'gnus-topic)
33 (require 'gnus-art)
34
35 ;;; Widgets:
36
37 (defun gnus-custom-mode ()
38   "Major mode for editing Gnus customization buffers.
39
40 The following commands are available:
41
42 \\[widget-forward]              Move to next button or editable field.
43 \\[widget-backward]             Move to previous button or editable field.
44 \\[widget-button-click]         Activate button under the mouse pointer.
45 \\[widget-button-press]         Activate button under point.
46
47 Entry to this mode calls the value of `gnus-custom-mode-hook'
48 if that value is non-nil."
49   (kill-all-local-variables)
50   (setq major-mode 'gnus-custom-mode
51         mode-name "Gnus Customize")
52   (use-local-map widget-keymap)
53   ;; Emacs 21 stuff:
54   (when (and (facep 'custom-button-face)
55              (facep 'custom-button-pressed-face))
56     (set (make-local-variable 'widget-button-face)
57          'custom-button-face)
58     (set (make-local-variable 'widget-button-pressed-face)
59          'custom-button-pressed-face)
60     (set (make-local-variable 'widget-mouse-face)
61          'custom-button-pressed-face))
62   (when (and (boundp 'custom-raised-buttons)
63              (symbol-value 'custom-raised-buttons))
64     (set (make-local-variable 'widget-push-button-prefix) "")
65     (set (make-local-variable 'widget-push-button-suffix) "")
66     (set (make-local-variable 'widget-link-prefix) "")
67     (set (make-local-variable 'widget-link-suffix) ""))
68   (gnus-run-hooks 'gnus-custom-mode-hook))
69
70 ;;; Group Customization:
71
72 (defconst gnus-group-parameters
73   '((extra-aliases (choice
74                     :tag "Extra Aliases"
75                     (list
76                      :tag "List"
77                      (editable-list
78                       :inline t
79                       (gnus-email-address :tag "Address")))
80                     (gnus-email-address :tag "Address")) "\
81 Store messages posted from or to this address in this group.
82
83 You must be using gnus-group-split for this to work.  The VALUE of the
84 nnmail-split-fancy SPLIT generated for this group will match these
85 addresses.")
86
87     (split-regexp (regexp :tag "gnus-group-split Regular Expression") "\
88 Like gnus-group-split Address, but expects a regular expression.")
89
90     (split-exclude (list :tag "gnus-group-split Restricts"
91                          (editable-list
92                           :inline t (regexp :tag "Restrict"))) "\
93 Regular expression that cancels gnus-group-split matches.
94
95 Each entry is added to the nnmail-split-fancy SPLIT as a separate
96 RESTRICT clause.")
97
98     (split-spec (choice :tag "gnus-group-split Overrider"
99                         (sexp :tag "Fancy Split")
100                         (const :tag "Catch All" catch-all)
101                         (const :tag "Ignore" nil)) "\
102 Override all other gnus-group-split fields.
103
104 In `Fancy Split', you can enter any nnmail-split-fancy SPLIT.  Note
105 that the name of this group won't be automatically assumed, you have
106 to add it to the SPLITs yourself.  This means you can use such splits
107 to split messages to other groups too.
108
109 If you select `Catch All', this group will get postings for any
110 messages not matched in any other group.  It overrides the variable
111 gnus-group-split-default-catch-all-group.
112
113 Selecting `Ignore' forces no SPLIT to be generated for this group,
114 disabling all other gnus-group-split fields.")
115
116     (broken-reply-to (const :tag "Broken Reply To" t) "\
117 Ignore `Reply-To' headers in this group.
118
119 That can be useful if you're reading a mailing list group where the
120 listserv has inserted `Reply-To' headers that point back to the
121 listserv itself.  This is broken behavior.  So there!")
122
123     (to-group (string :tag "To Group") "\
124 All posts will be sent to the specified group.")
125
126     (gcc-self (choice :tag  "GCC"
127                       :value t
128                       (const :tag "To current group" t)
129                       (const none)
130                       (string :format "%v" :hide-front-space t)) "\
131 Specify default value for GCC header.
132
133 If this symbol is present in the group parameter list and set to `t',
134 new composed messages will be `Gcc''d to the current group.  If it is
135 present and set to `none', no `Gcc:' header will be generated, if it
136 is present and a string, this string will be inserted literally as a
137 `gcc' header (this symbol takes precedence over any default `Gcc'
138 rules as described later).")
139
140     (expiry-wait (choice :tag  "Expire Wait"
141                          :value never
142                          (const never)
143                          (const immediate)
144                          (number :hide-front-space t
145                                  :format "%v")) "\
146 When to expire.
147
148 Overrides any `nnmail-expiry-wait' and `nnmail-expiry-wait-function'
149 when expiring expirable messages.  The value can either be a number of
150 days (not necessarily an integer) or the symbols `never' or
151 `immediate'.")
152
153     (expiry-target (choice :tag "Expiry Target"
154                            :value delete
155                            (const delete)
156                            (function :format "%v" nnmail-)
157                            string) "\
158 Where expired messages end up.
159
160 Overrides `nnmail-expiry-target', which see.")
161
162     (score-file (file :tag "Score File") "\
163 Make the specified file into the current score file.
164 This means that all score commands you issue will end up in this file.")
165
166     (adapt-file (file :tag "Adapt File") "\
167 Make the specified file into the current adaptive file.
168 All adaptive score entries will be put into this file.")
169
170     (admin-address (gnus-email-address :tag "Admin Address") "\
171 Administration address for a mailing list.
172
173 When unsubscribing to a mailing list you should never send the
174 unsubscription notice to the mailing list itself.  Instead, you'd
175 send messages to the administrative address.  This parameter allows
176 you to put the admin address somewhere convenient.")
177
178     (display (choice :tag "Display"
179                      :value default
180                      (const all)
181                      (const default)) "\
182 Which articles to display on entering the group.
183
184 `all'
185      Display all articles, both read and unread.
186
187 `default'
188      Display the default visible articles, which normally includes
189      unread and ticked articles.")
190
191     (comment (string :tag  "Comment") "\
192 An arbitrary comment on the group.")
193
194     (visible (const :tag "Permanently visible" t) "\
195 Always display this group, even when there are no unread articles
196 in it..")
197
198     (highlight-words 
199      (choice :tag "Highlight words"
200              :value nil
201              (repeat (list (regexp :tag "Highlight regexp")
202                            (number :tag "Group for entire word" 0)
203                            (number :tag "Group for displayed part" 0)
204                            (symbol :tag "Face" 
205                                    gnus-emphasis-highlight-words))))
206      "highlight regexps.
207 See gnus-emphasis-alist.")
208
209     (posting-style
210      (choice :tag "Posting style"
211              :value nil
212              (repeat (list
213                       (choice :tag "Type"
214                               :value nil
215                               (const signature)
216                               (const signature-file) 
217                               (const organization) 
218                               (const address)
219                               (const name)
220                               (const body))
221                       (string :format "%v"))))
222      "post style.
223 See gnus-posting-styles."))
224   "Alist of valid group or topic parameters.
225
226 Each entry has the form (NAME TYPE DOC), where NAME is the parameter
227 itself (a symbol), TYPE is the parameters type (a sexp widget), and
228 DOC is a documentation string for the parameter.")
229
230 (defconst gnus-extra-topic-parameters
231   '((subscribe (regexp :tag "Subscribe") "\
232 If `gnus-subscribe-newsgroup-method' or 
233 `gnus-subscribe-options-newsgroup-method' is set to
234 `gnus-subscribe-topics', new groups that matches this regexp will
235 automatically be subscribed to this topic")) 
236   "Alist of topic parameters that are not also group parameters.
237
238 Each entry has the form (NAME TYPE DOC), where NAME is the parameter
239 itself (a symbol), TYPE is the parameters type (a sexp widget), and
240 DOC is a documentation string for the parameter.")
241
242 (defconst gnus-extra-group-parameters
243   '((uidvalidity (string :tag "IMAP uidvalidity") "\
244 Server-assigned value attached to IMAP groups, used to maintain consistency."))
245   "Alist of group parameters that are not also topic parameters.
246
247 Each entry has the form (NAME TYPE DOC), where NAME is the parameter
248 itself (a symbol), TYPE is the parameters type (a sexp widget), and
249 DOC is a documentation string for the parameter.")
250 (defvar gnus-custom-params)
251 (defvar gnus-custom-method)
252 (defvar gnus-custom-group)
253 (defvar gnus-custom-topic)
254
255 (defun gnus-group-customize (group &optional topic)
256   "Edit the group or topic on the current line."
257   (interactive (list (gnus-group-group-name) (gnus-group-topic-name)))
258   (let (info
259         (types (mapcar (lambda (entry)
260                          `(cons :format "%v%h\n"
261                                 :doc ,(nth 2 entry)
262                                 (const :format "" ,(nth 0 entry))
263                                 ,(nth 1 entry)))
264                        (append (reverse gnus-group-parameters-more)
265                                gnus-group-parameters 
266                                (if group
267                                    gnus-extra-group-parameters
268                                  gnus-extra-topic-parameters)))))
269     (unless (or group topic)
270       (error "No group on current line"))
271     (when (and group topic)
272       (error "Both a group an topic on current line"))
273     (unless (or topic (setq info (gnus-get-info group)))
274       (error "Killed group; can't be edited"))
275     ;; Ready.
276     (kill-buffer (gnus-get-buffer-create "*Gnus Customize*"))
277     (switch-to-buffer (gnus-get-buffer-create "*Gnus Customize*"))
278     (gnus-custom-mode)
279     (make-local-variable 'gnus-custom-group)
280     (setq gnus-custom-group group)
281     (make-local-variable 'gnus-custom-topic)
282     (setq gnus-custom-topic topic)
283     (buffer-disable-undo)
284     (widget-insert "Customize the ")
285     (if group
286         (widget-create 'info-link
287                        :help-echo "Push me to learn more."
288                        :tag "group parameters"
289                        "(gnus)Group Parameters")
290       (widget-create 'info-link
291                      :help-echo "Push me to learn more."
292                      :tag  "topic parameters"
293                      "(gnus)Topic Parameters"))
294     (widget-insert " for <")
295     (widget-insert (gnus-group-decoded-name (or group topic)))
296     (widget-insert "> and press ")
297     (widget-create 'push-button
298                    :tag "done"
299                    :help-echo "Push me when done customizing."
300                    :action 'gnus-group-customize-done)
301     (widget-insert ".\n\n")
302     (make-local-variable 'gnus-custom-params)
303     (setq gnus-custom-params
304           (widget-create 'group
305                          :value (if group
306                                     (gnus-info-params info)
307                                   (gnus-topic-parameters topic))
308                          `(set :inline t
309                                :greedy t
310                                :tag "Parameters"
311                                :format "%t:\n%h%v"
312                                :doc "\
313 These special parameters are recognized by Gnus.
314 Check the [ ] for the parameters you want to apply to this group or
315 to the groups in this topic, then edit the value to suit your taste."
316                                ,@types)
317                          '(repeat :inline t
318                                   :tag "Variables"
319                                   :format "%t:\n%h%v%i\n\n"
320                                   :doc "\
321 Set variables local to the group you are entering.
322
323 If you want to turn threading off in `news.answers', you could put
324 `(gnus-show-threads nil)' in the group parameters of that group.
325 `gnus-show-threads' will be made into a local variable in the summary
326 buffer you enter, and the form `nil' will be `eval'ed there.
327
328 This can also be used as a group-specific hook function, if you'd
329 like.  If you want to hear a beep when you enter a group, you could
330 put something like `(dummy-variable (ding))' in the parameters of that
331 group.  `dummy-variable' will be set to the result of the `(ding)'
332 form, but who cares?"
333                                   (list :format "%v" :value (nil nil)
334                                         (symbol :tag "Variable")
335                                         (sexp :tag
336                                               "Value")))
337
338                          '(repeat :inline t
339                                   :tag "Unknown entries"
340                                   sexp)))
341     (when group
342       (widget-insert "\n\nYou can also edit the ")
343       (widget-create 'info-link
344                      :tag "select method"
345                      :help-echo "Push me to learn more about select methods."
346                      "(gnus)Select Methods")
347       (widget-insert " for the group.\n")
348       (setq gnus-custom-method
349             (widget-create 'sexp
350                            :tag "Method"
351                            :value (gnus-info-method info))))
352     (use-local-map widget-keymap)
353     (widget-setup)
354     (buffer-enable-undo)
355     (goto-char (point-min))))
356
357 (defun gnus-group-customize-done (&rest ignore)
358   "Apply changes and bury the buffer."
359   (interactive)
360   (if gnus-custom-topic
361       (gnus-topic-set-parameters gnus-custom-topic
362                                  (widget-value gnus-custom-params))
363     (gnus-group-edit-group-done 'params gnus-custom-group
364                                 (widget-value gnus-custom-params))
365     (gnus-group-edit-group-done 'method gnus-custom-group
366                                 (widget-value gnus-custom-method)))
367   (bury-buffer))
368
369 ;;; Score Customization:
370
371 (defconst gnus-score-parameters
372   '((mark (number :tag "Mark") "\
373 The value of this entry should be a number.
374 Any articles with a score lower than this number will be marked as read.")
375
376     (expunge (number :tag "Expunge") "\
377 The value of this entry should be a number.
378 Any articles with a score lower than this number will be removed from
379 the summary buffer.")
380
381     (mark-and-expunge (number :tag "Mark-and-expunge") "\
382 The value of this entry should be a number.
383 Any articles with a score lower than this number will be marked as
384 read and removed from the summary buffer.")
385
386     (thread-mark-and-expunge (number :tag "Thread-mark-and-expunge") "\
387 The value of this entry should be a number.
388 All articles that belong to a thread that has a total score below this
389 number will be marked as read and removed from the summary buffer.
390 `gnus-thread-score-function' says how to compute the total score
391 for a thread.")
392
393     (files (repeat :inline t :tag "Files" file) "\
394 The value of this entry should be any number of file names.
395 These files are assumed to be score files as well, and will be loaded
396 the same way this one was.")
397
398     (exclude-files (repeat :inline t :tag "Exclude-files" file) "\
399 The clue of this entry should be any number of files.
400 These files will not be loaded, even though they would normally be so,
401 for some reason or other.")
402
403     (eval (sexp :tag "Eval" :value nil) "\
404 The value of this entry will be `eval'el.
405 This element will be ignored when handling global score files.")
406
407     (read-only (boolean :tag "Read-only" :value t) "\
408 Read-only score files will not be updated or saved.
409 Global score files should feature this atom.")
410
411     (orphan (number :tag "Orphan") "\
412 The value of this entry should be a number.
413 Articles that do not have parents will get this number added to their
414 scores.  Imagine you follow some high-volume newsgroup, like
415 `comp.lang.c'.  Most likely you will only follow a few of the threads,
416 also want to see any new threads.
417
418 You can do this with the following two score file entries:
419
420      (orphan -500)
421      (mark-and-expunge -100)
422
423 When you enter the group the first time, you will only see the new
424 threads.  You then raise the score of the threads that you find
425 interesting (with `I T' or `I S'), and ignore (`C y') the rest.
426 Next time you enter the group, you will see new articles in the
427 interesting threads, plus any new threads.
428
429 I.e.---the orphan score atom is for high-volume groups where there
430 exist a few interesting threads which can't be found automatically
431 by ordinary scoring rules.")
432
433     (adapt (choice :tag "Adapt"
434                    (const t)
435                    (const ignore)
436                    (sexp :format "%v"
437                          :hide-front-space t)) "\
438 This entry controls the adaptive scoring.
439 If it is `t', the default adaptive scoring rules will be used.  If it
440 is `ignore', no adaptive scoring will be performed on this group.  If
441 it is a list, this list will be used as the adaptive scoring rules.
442 If it isn't present, or is something other than `t' or `ignore', the
443 default adaptive scoring rules will be used.  If you want to use
444 adaptive scoring on most groups, you'd set `gnus-use-adaptive-scoring'
445 to `t', and insert an `(adapt ignore)' in the groups where you do not
446 want adaptive scoring.  If you only want adaptive scoring in a few
447 groups, you'd set `gnus-use-adaptive-scoring' to `nil', and insert
448 `(adapt t)' in the score files of the groups where you want it.")
449
450     (adapt-file (file :tag "Adapt-file") "\
451 All adaptive score entries will go to the file named by this entry.
452 It will also be applied when entering the group.  This atom might
453 be handy if you want to adapt on several groups at once, using the
454 same adaptive file for a number of groups.")
455
456     (local (repeat :tag "Local"
457                    (group :value (nil nil)
458                           (symbol :tag "Variable")
459                           (sexp :tag "Value"))) "\
460 The value of this entry should be a list of `(VAR VALUE)' pairs.
461 Each VAR will be made buffer-local to the current summary buffer,
462 and set to the value specified.  This is a convenient, if somewhat
463 strange, way of setting variables in some groups if you don't like
464 hooks much.")
465     (touched (sexp :format "Touched\n") "Internal variable."))
466   "Alist of valid symbolic score parameters.
467
468 Each entry has the form (NAME TYPE DOC), where NAME is the parameter
469 itself (a symbol), TYPE is the parameters type (a sexp widget), and DOC is a
470 documentation string for the parameter.")
471
472 (define-widget 'gnus-score-string 'group
473   "Edit score entries for string-valued headers."
474   :convert-widget 'gnus-score-string-convert)
475
476 (defun gnus-score-string-convert (widget)
477   ;; Set args appropriately.
478   (let* ((tag (widget-get widget :tag))
479          (item `(const :format "" :value ,(downcase tag)))
480          (match '(string :tag "Match"))
481          (score '(choice :tag "Score"
482                          (const :tag "default" nil)
483                          (integer :format "%v"
484                                   :hide-front-space t)))
485          (expire '(choice :tag "Expire"
486                           (const :tag "off" nil)
487                           (integer :format "%v"
488                                    :hide-front-space t)))
489          (type '(choice :tag "Type"
490                         :value s
491                         ;; I should really create a forgiving :match
492                         ;; function for each type below, that only
493                         ;; looked at the first letter.
494                         (const :tag "Regexp" r)
495                         (const :tag "Regexp (fixed case)" R)
496                         (const :tag "Substring" s)
497                         (const :tag "Substring (fixed case)" S)
498                         (const :tag "Exact" e)
499                         (const :tag "Exact (fixed case)" E)
500                         (const :tag "Word" w)
501                         (const :tag "Word (fixed case)" W)
502                         (const :tag "default" nil)))
503          (group `(group ,match ,score ,expire ,type))
504          (doc (concat (or (widget-get widget :doc)
505                           (concat "Change score based on the " tag
506                                   " header.\n"))
507                       "
508 You can have an arbitrary number of score entries for this header,
509 each score entry has four elements:
510
511 1. The \"match element\".  This should be the string to look for in the
512    header.
513
514 2. The \"score element\".  This number should be an integer in the
515    neginf to posinf interval.  This number is added to the score
516    of the article if the match is successful.  If this element is
517    not present, the `gnus-score-interactive-default-score' number
518    will be used instead.  This is 1000 by default.
519
520 3. The \"date element\".  This date says when the last time this score
521    entry matched, which provides a mechanism for expiring the
522    score entries.  It this element is not present, the score
523    entry is permanent.  The date is represented by the number of
524    days since December 31, 1 ce.
525
526 4. The \"type element\".  This element specifies what function should
527    be used to see whether this score entry matches the article.
528
529    There are the regexp, as well as substring types, and exact match,
530    and word match types.  If this element is not present, Gnus will
531    assume that substring matching should be used.  There is case
532    sensitive variants of all match types.")))
533     (widget-put widget :args `(,item
534                                (repeat :inline t
535                                        :indent 0
536                                        :tag ,tag
537                                        :doc ,doc
538                                        :format "%t:\n%h%v%i\n\n"
539                                        (choice :format "%v"
540                                                :value ("" nil nil s)
541                                                ,group
542                                                sexp)))))
543   widget)
544
545 (define-widget 'gnus-score-integer 'group
546   "Edit score entries for integer-valued headers."
547   :convert-widget 'gnus-score-integer-convert)
548
549 (defun gnus-score-integer-convert (widget)
550   ;; Set args appropriately.
551   (let* ((tag (widget-get widget :tag))
552          (item `(const :format "" :value ,(downcase tag)))
553          (match '(integer :tag "Match"))
554          (score '(choice :tag "Score"
555                          (const :tag "default" nil)
556                          (integer :format "%v"
557                                   :hide-front-space t)))
558          (expire '(choice :tag "Expire"
559                           (const :tag "off" nil)
560                           (integer :format "%v"
561                                    :hide-front-space t)))
562          (type '(choice :tag "Type"
563                         :value <
564                         (const <)
565                         (const >)
566                         (const =)
567                         (const >=)
568                         (const <=)))
569          (group `(group ,match ,score ,expire ,type))
570          (doc (concat (or (widget-get widget :doc)
571                           (concat "Change score based on the " tag
572                                   " header.")))))
573     (widget-put widget :args `(,item
574                                (repeat :inline t
575                                        :indent 0
576                                        :tag ,tag
577                                        :doc ,doc
578                                        :format "%t:\n%h%v%i\n\n"
579                                        ,group))))
580   widget)
581
582 (define-widget 'gnus-score-date 'group
583   "Edit score entries for date-valued headers."
584   :convert-widget 'gnus-score-date-convert)
585
586 (defun gnus-score-date-convert (widget)
587   ;; Set args appropriately.
588   (let* ((tag (widget-get widget :tag))
589          (item `(const :format "" :value ,(downcase tag)))
590          (match '(string :tag "Match"))
591          (score '(choice :tag "Score"
592                          (const :tag "default" nil)
593                          (integer :format "%v"
594                                   :hide-front-space t)))
595          (expire '(choice :tag "Expire"
596                           (const :tag "off" nil)
597                           (integer :format "%v"
598                                    :hide-front-space t)))
599          (type '(choice :tag "Type"
600                         :value regexp
601                         (const regexp)
602                         (const before)
603                         (const at)
604                         (const after)))
605          (group `(group ,match ,score ,expire ,type))
606          (doc (concat (or (widget-get widget :doc)
607                           (concat "Change score based on the " tag
608                                   " header."))
609                       "
610 For the Date header we have three kinda silly match types: `before',
611 `at' and `after'.  I can't really imagine this ever being useful, but,
612 like, it would feel kinda silly not to provide this function.  Just in
613 case.  You never know.  Better safe than sorry.  Once burnt, twice
614 shy.  Don't judge a book by its cover.  Never not have sex on a first
615 date.  (I have been told that at least one person, and I quote,
616 \"found this function indispensable\", however.)
617
618 A more useful match type is `regexp'.  With it, you can match the date
619 string using a regular expression.  The date is normalized to ISO8601
620 compact format first---`YYYYMMDDTHHMMSS'.  If you want to match all
621 articles that have been posted on April 1st in every year, you could
622 use `....0401.........' as a match string, for instance.  (Note that
623 the date is kept in its original time zone, so this will match
624 articles that were posted when it was April 1st where the article was
625 posted from.  Time zones are such wholesome fun for the whole family,
626 eh?")))
627     (widget-put widget :args `(,item
628                                (repeat :inline t
629                                        :indent 0
630                                        :tag ,tag
631                                        :doc ,doc
632                                        :format "%t:\n%h%v%i\n\n"
633                                        ,group))))
634   widget)
635
636 (defvar gnus-custom-scores)
637 (defvar gnus-custom-score-alist)
638
639 (defun gnus-score-customize (file)
640   "Customize score file FILE.
641 When called interactively, FILE defaults to the current score file.
642 This can be changed using the `\\[gnus-score-change-score-file]' command."
643   (interactive (list gnus-current-score-file))
644   (unless file
645     (error (format "No score file for %s" 
646                    (gnus-group-decoded-name gnus-newsgroup-name))))
647   (let ((scores (gnus-score-load file))
648         (types (mapcar (lambda (entry)
649                          `(group :format "%v%h\n"
650                                  :doc ,(nth 2 entry)
651                                  (const :format "" ,(nth 0 entry))
652                                  ,(nth 1 entry)))
653                        gnus-score-parameters)))
654     ;; Ready.
655     (kill-buffer (gnus-get-buffer-create "*Gnus Customize*"))
656     (switch-to-buffer (gnus-get-buffer-create "*Gnus Customize*"))
657     (gnus-custom-mode)
658     (make-local-variable 'gnus-custom-score-alist)
659     (setq gnus-custom-score-alist scores)
660     (widget-insert "Customize the ")
661     (widget-create 'info-link
662                    :help-echo "Push me to learn more."
663                    :tag "score entries"
664                    "(gnus)Score File Format")
665     (widget-insert " for\n\t")
666     (widget-insert file)
667     (widget-insert "\nand press ")
668     (widget-create 'push-button
669                    :tag "done"
670                    :help-echo "Push me when done customizing."
671                    :action 'gnus-score-customize-done)
672     (widget-insert ".\n
673 Check the [ ] for the entries you want to apply to this score file, then
674 edit the value to suit your taste.  Don't forget to mark the checkbox,
675 if you do all your changes will be lost.  ")
676     (widget-create 'push-button
677                    :action (lambda (&rest ignore)
678                              (require 'gnus-audio)
679                              (gnus-audio-play "Evil_Laugh.au"))
680                    "Bhahahah!")
681     (widget-insert "\n\n")
682     (make-local-variable 'gnus-custom-scores)
683     (setq gnus-custom-scores
684           (widget-create 'group
685                          :value scores
686                          `(checklist :inline t
687                                      :greedy t
688                                      (gnus-score-string :tag "From")
689                                      (gnus-score-string :tag "Subject")
690                                      (gnus-score-string :tag "References")
691                                      (gnus-score-string :tag "Xref")
692                                      (gnus-score-string :tag "Extra")
693                                      (gnus-score-string :tag "Message-ID")
694                                      (gnus-score-integer :tag "Lines")
695                                      (gnus-score-integer :tag "Chars")
696                                      (gnus-score-date :tag "Date")
697                                      (gnus-score-string :tag "Head"
698                                                         :doc "\
699 Match all headers in the article.
700
701 Using one of `Head', `Body', `All' will slow down scoring considerable.
702 ")
703                                      (gnus-score-string :tag "Body"
704                                                         :doc "\
705 Match the body sans header of the article.
706
707 Using one of `Head', `Body', `All' will slow down scoring considerable.
708 ")
709                                      (gnus-score-string :tag "All"
710                                                         :doc "\
711 Match the entire article, including both headers and body.
712
713 Using one of `Head', `Body', `All' will slow down scoring
714 considerable.
715 ")
716                                      (gnus-score-string :tag
717                                                         "Followup"
718                                                         :doc "\
719 Score all followups to the specified authors.
720
721 This entry is somewhat special, in that it will match the `From:'
722 header, and affect the score of not only the matching articles, but
723 also all followups to the matching articles.  This allows you
724 e.g. increase the score of followups to your own articles, or decrease
725 the score of followups to the articles of some known trouble-maker.
726 ")
727                                      (gnus-score-string :tag "Thread"
728                                                         :doc "\
729 Add a score entry on all articles that are part of a thread.
730
731 This match key works along the same lines as the `Followup' match key.
732 If you say that you want to score on a (sub-)thread that is started by
733 an article with a `Message-ID' X, then you add a `thread' match.  This
734 will add a new `thread' match for each article that has X in its
735 `References' header.  (These new `thread' matches will use the
736 `Message-ID's of these matching articles.)  This will ensure that you
737 can raise/lower the score of an entire thread, even though some
738 articles in the thread may not have complete `References' headers.
739 Note that using this may lead to undeterministic scores of the
740 articles in the thread.
741 ")
742                                      ,@types)
743                          '(repeat :inline t
744                                   :tag "Unknown entries"
745                                   sexp)))
746     (use-local-map widget-keymap)
747     (widget-setup)))
748
749 (defun gnus-score-customize-done (&rest ignore)
750   "Reset the score alist with the present value."
751   (let ((alist gnus-custom-score-alist)
752         (value (widget-value gnus-custom-scores)))
753     (setcar alist (car value))
754     (setcdr alist (cdr value))
755     (gnus-score-set 'touched '(t) alist))
756   (bury-buffer))
757
758 ;;; The End:
759
760 (provide 'gnus-cus)
761
762 ;;; gnus-cus.el ends here