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