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