1 ;;; gnus-cus.el --- customization commands for Gnus
3 ;; Copyright (C) 1996, 1999, 2000, 2001, 2002, 2003
4 ;; Free Software Foundation, Inc.
6 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
9 ;; This file is part of GNU Emacs.
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)
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.
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.
39 (defun gnus-custom-mode ()
40 "Major mode for editing Gnus customization buffers.
42 The following commands are available:
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.
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)
56 (when (and (facep 'custom-button-face)
57 (facep 'custom-button-pressed-face))
58 (set (make-local-variable 'widget-button-face)
60 (set (make-local-variable 'widget-button-pressed-face)
61 'custom-button-pressed-face)
62 (set (make-local-variable 'widget-mouse-face)
63 'custom-button-pressed-face))
64 (when (and (boundp 'custom-raised-buttons)
65 (symbol-value 'custom-raised-buttons))
66 (set (make-local-variable 'widget-push-button-prefix) "")
67 (set (make-local-variable 'widget-push-button-suffix) "")
68 (set (make-local-variable 'widget-link-prefix) "")
69 (set (make-local-variable 'widget-link-suffix) ""))
70 (gnus-run-hooks 'gnus-custom-mode-hook))
72 ;;; Group Customization:
74 (defconst gnus-group-parameters
75 '((extra-aliases (choice
81 (gnus-email-address :tag "Address")))
82 (gnus-email-address :tag "Address")) "\
83 Store messages posted from or to this address in this group.
85 You must be using gnus-group-split for this to work. The VALUE of the
86 nnmail-split-fancy SPLIT generated for this group will match these
89 (split-regexp (regexp :tag "gnus-group-split Regular Expression") "\
90 Like gnus-group-split Address, but expects a regular expression.")
92 (split-exclude (list :tag "gnus-group-split Restricts"
94 :inline t (regexp :tag "Restrict"))) "\
95 Regular expression that cancels gnus-group-split matches.
97 Each entry is added to the nnmail-split-fancy SPLIT as a separate
100 (split-spec (choice :tag "gnus-group-split Overrider"
101 (sexp :tag "Fancy Split")
102 (const :tag "Catch All" catch-all)
103 (const :tag "Ignore" nil)) "\
104 Override all other gnus-group-split fields.
106 In `Fancy Split', you can enter any nnmail-split-fancy SPLIT. Note
107 that the name of this group won't be automatically assumed, you have
108 to add it to the SPLITs yourself. This means you can use such splits
109 to split messages to other groups too.
111 If you select `Catch All', this group will get postings for any
112 messages not matched in any other group. It overrides the variable
113 gnus-group-split-default-catch-all-group.
115 Selecting `Ignore' forces no SPLIT to be generated for this group,
116 disabling all other gnus-group-split fields.")
118 (broken-reply-to (const :tag "Broken Reply To" t) "\
119 Ignore `Reply-To' headers in this group.
121 That can be useful if you're reading a mailing list group where the
122 listserv has inserted `Reply-To' headers that point back to the
123 listserv itself. This is broken behavior. So there!")
125 (to-group (string :tag "To Group") "\
126 All posts will be sent to the specified group.")
128 (gcc-self (choice :tag "GCC"
130 (const :tag "To current group" t)
132 (string :format "%v" :hide-front-space t)) "\
133 Specify default value for GCC header.
135 If this symbol is present in the group parameter list and set to t,
136 new composed messages will be `Gcc''d to the current group. If it is
137 present and set to `none', no `Gcc:' header will be generated, if it
138 is present and a string, this string will be inserted literally as a
139 `gcc' header (this symbol takes precedence over any default `Gcc'
140 rules as described later).")
142 (expiry-wait (choice :tag "Expire Wait"
146 (number :hide-front-space t
150 Overrides any `nnmail-expiry-wait' and `nnmail-expiry-wait-function'
151 when expiring expirable messages. The value can either be a number of
152 days (not necessarily an integer) or the symbols `never' or
155 (expiry-target (choice :tag "Expiry Target"
158 (function :format "%v" nnmail-)
160 Where expired messages end up.
162 Overrides `nnmail-expiry-target'.")
164 (score-file (file :tag "Score File") "\
165 Make the specified file into the current score file.
166 This means that all score commands you issue will end up in this file.")
168 (adapt-file (file :tag "Adapt File") "\
169 Make the specified file into the current adaptive file.
170 All adaptive score entries will be put into this file.")
172 (admin-address (gnus-email-address :tag "Admin Address") "\
173 Administration address for a mailing list.
175 When unsubscribing to a mailing list you should never send the
176 unsubscription notice to the mailing list itself. Instead, you'd
177 send messages to the administrative address. This parameter allows
178 you to put the admin address somewhere convenient.")
180 (display (choice :tag "Display"
185 (sexp :tag "Other")) "\
186 Which articles to display on entering the group.
189 Display all articles, both read and unread.
192 Display the last NUMBER articles in the group. This is the same as
193 entering the group with C-u NUMBER.
196 Display the default visible articles, which normally includes
197 unread and ticked articles.
200 Display the articles that satisfy the S-expression. The S-expression
201 should be in an array form.")
203 (comment (string :tag "Comment") "\
204 An arbitrary comment on the group.")
206 (visible (const :tag "Permanently visible" t) "\
207 Always display this group, even when there are no unread articles
211 (choice :tag "Highlight words"
213 (repeat (list (regexp :tag "Highlight regexp")
214 (number :tag "Group for entire word" 0)
215 (number :tag "Group for displayed part" 0)
217 gnus-emphasis-highlight-words))))
219 See `gnus-emphasis-alist'.")
222 (choice :tag "Posting style"
228 (const signature-file)
234 (string :format "%v"))))
236 See `gnus-posting-styles'."))
237 "Alist of valid group or topic parameters.
239 Each entry has the form (NAME TYPE DOC), where NAME is the parameter
240 itself (a symbol), TYPE is the parameters type (a sexp widget), and
241 DOC is a documentation string for the parameter.")
243 (defconst gnus-extra-topic-parameters
244 '((subscribe (regexp :tag "Subscribe") "\
245 If `gnus-subscribe-newsgroup-method' or
246 `gnus-subscribe-options-newsgroup-method' is set to
247 `gnus-subscribe-topics', new groups that matches this regexp will
248 automatically be subscribed to this topic")
249 (subscribe-level (integer :tag "Subscribe Level" :value 1) "\
250 If this topic parameter is set, when new groups are subscribed
251 automatically under this topic (via the `subscribe' topic parameter)
252 assign this level to the group, rather than the default level
253 set in `gnus-level-default-subscribed'"))
254 "Alist of topic parameters that are not also group parameters.
256 Each entry has the form (NAME TYPE DOC), where NAME is the parameter
257 itself (a symbol), TYPE is the parameters type (a sexp widget), and
258 DOC is a documentation string for the parameter.")
260 (defconst gnus-extra-group-parameters
261 '((uidvalidity (string :tag "IMAP uidvalidity") "\
262 Server-assigned value attached to IMAP groups, used to maintain consistency."))
263 "Alist of group parameters that are not also topic parameters.
265 Each entry has the form (NAME TYPE DOC), where NAME is the parameter
266 itself (a symbol), TYPE is the parameters type (a sexp widget), and
267 DOC is a documentation string for the parameter.")
270 (defconst gnus-agent-parameters
272 (sexp :tag "Selection Predicate" :value false)
273 "Predicate used to automatically select articles for downloading."
274 gnus-agent-cat-predicate)
276 (choice :tag "Score File" :value nil
277 (const file :tag "Use group's score files")
278 (repeat (list (string :format "%v" :tag "File name"))))
279 "Which score files to use when using score to select articles to fetch.
282 All articles will be scored to zero (0).
285 The group's score files will be used to score the articles.
288 A list of score file names."
289 gnus-agent-cat-score-file)
291 (integer :tag "Max Length of Short Article" :value "")
292 "The SHORT predicate will evaluate to true when the article is
293 shorter than this length." gnus-agent-cat-length-when-short)
295 (integer :tag "Min Length of Long Article" :value "")
296 "The LONG predicate will evaluate to true when the article is
297 longer than this length." gnus-agent-cat-length-when-long)
299 (integer :tag "Low Score Limit" :value "")
300 "The LOW predicate will evaluate to true when the article scores
301 lower than this limit." gnus-agent-cat-low-score)
303 (integer :tag "High Score Limit" :value "")
304 "The HIGH predicate will evaluate to true when the article scores
305 higher than this limit." gnus-agent-cat-high-score)
306 (agent-days-until-old
307 (integer :tag "Days Until Old" :value "")
308 "The OLD predicate will evaluate to true when the fetched article
309 has been stored locally for at least this many days."
310 gnus-agent-cat-days-until-old)
311 (agent-enable-expiration
312 (radio :tag "Expire in this Group or Topic" :value nil
313 ; (const :format "Inherit " nil)
314 (const :format "Enable " ENABLE)
315 (const :format "Disable " DISABLE))
316 "\nEnable, or disable, agent expiration in this group or topic."
317 gnus-agent-cat-enable-expiration) )
318 "Alist of group parameters that are not also topic parameters.
320 Each entry has the form (NAME TYPE DOC), where NAME is the parameter
321 itself (a symbol), TYPE is the parameters type (a sexp widget), and
322 DOC is a documentation string for the parameter."))
324 (defvar gnus-custom-params)
325 (defvar gnus-custom-method)
326 (defvar gnus-custom-group)
327 (defvar gnus-custom-topic)
329 (defun gnus-group-customize (group &optional topic)
330 "Edit the group or topic on the current line."
331 (interactive (list (gnus-group-group-name) (gnus-group-topic-name)))
333 (types (mapcar (lambda (entry)
334 `(cons :format "%v%h\n"
336 (const :format "" ,(nth 0 entry))
338 (append (reverse gnus-group-parameters-more)
339 gnus-group-parameters
341 gnus-extra-group-parameters
342 gnus-extra-topic-parameters))))
343 (agent (mapcar (lambda (entry)
344 (let ((type (nth 1 entry))
347 (setq type (copy-sequence type)))
349 (setq vcons (cdr (memq :value type)))
351 (if (symbolp (car vcons))
353 (setcar vcons (symbol-value (car vcons)))
355 `(cons :format "%v%h\n"
357 (const :format "" ,(nth 0 entry))
360 gnus-agent-parameters))))
361 (unless (or group topic)
362 (error "No group on current line"))
363 (when (and group topic)
364 (error "Both a group an topic on current line"))
365 (unless (or topic (setq info (gnus-get-info group)))
366 (error "Killed group; can't be edited"))
368 (gnus-kill-buffer (gnus-get-buffer-create "*Gnus Customize*"))
369 (switch-to-buffer (gnus-get-buffer-create "*Gnus Customize*"))
371 (make-local-variable 'gnus-custom-group)
372 (setq gnus-custom-group group)
373 (make-local-variable 'gnus-custom-topic)
374 (setq gnus-custom-topic topic)
375 (buffer-disable-undo)
376 (widget-insert "Customize the ")
378 (widget-create 'info-link
379 :help-echo "Push me to learn more."
380 :tag "group parameters"
381 "(gnus)Group Parameters")
382 (widget-create 'info-link
383 :help-echo "Push me to learn more."
384 :tag "topic parameters"
385 "(gnus)Topic Parameters"))
386 (widget-insert " for <")
387 (widget-insert (gnus-group-decoded-name (or group topic)))
388 (widget-insert "> and press ")
389 (widget-create 'push-button
391 :help-echo "Push me when done customizing."
392 :action 'gnus-group-customize-done)
393 (widget-insert ".\n\n")
394 (make-local-variable 'gnus-custom-params)
396 (let ((values (if group
397 (gnus-info-params info)
398 (gnus-topic-parameters topic))))
400 ;; The parameters in values may contain duplicates. This is
401 ;; normally OK as assq returns the first. However, right here
402 ;; every duplicate ends up being displayed. So, rather than
403 ;; display them, remove them from the list.
405 (let ((tmp (setq values (gnus-copy-sequence values)))
408 (while (setq elem (assq (caar tmp) (cdr tmp)))
410 (setq tmp (cdr tmp))))
412 (setq gnus-custom-params
413 (apply 'widget-create 'group
416 (list `(set :inline t
421 These special parameters are recognized by Gnus.
422 Check the [ ] for the parameters you want to apply to this group or
423 to the groups in this topic, then edit the value to suit your taste."
428 :tag "Agent Parameters"
430 :doc "\ These agent parameters are
431 recognized by Gnus. They control article selection and expiration for
432 use in the unplugged cache. Check the [ ] for the parameters you want
433 to apply to this group or to the groups in this topic, then edit the
434 value to suit your taste.
436 For those interested, group parameters override topic parameters while
437 topic parameters override agent category parameters. Underlying
438 category parameters are the customizable variables." ,@agent))
441 :format "%t:\n%h%v%i\n\n"
443 Set variables local to the group you are entering.
445 If you want to turn threading off in `news.answers', you could put
446 `(gnus-show-threads nil)' in the group parameters of that group.
447 `gnus-show-threads' will be made into a local variable in the summary
448 buffer you enter, and the form nil will be `eval'ed there.
450 This can also be used as a group-specific hook function, if you'd
451 like. If you want to hear a beep when you enter a group, you could
452 put something like `(dummy-variable (ding))' in the parameters of that
453 group. `dummy-variable' will be set to the result of the `(ding)'
454 form, but who cares?"
455 (list :format "%v" :value (nil nil)
456 (symbol :tag "Variable")
461 :tag "Unknown entries"
464 (widget-insert "\n\nYou can also edit the ")
465 (widget-create 'info-link
467 :help-echo "Push me to learn more about select methods."
468 "(gnus)Select Methods")
469 (widget-insert " for the group.\n")
470 (setq gnus-custom-method
473 :value (gnus-info-method info))))
474 (use-local-map widget-keymap)
477 (goto-char (point-min))))
479 (defun gnus-group-customize-done (&rest ignore)
480 "Apply changes and bury the buffer."
482 (if gnus-custom-topic
483 (gnus-topic-set-parameters gnus-custom-topic
484 (widget-value gnus-custom-params))
485 (gnus-group-edit-group-done 'params gnus-custom-group
486 (widget-value gnus-custom-params))
487 (gnus-group-edit-group-done 'method gnus-custom-group
488 (widget-value gnus-custom-method)))
491 ;;; Score Customization:
493 (defconst gnus-score-parameters
494 '((mark (number :tag "Mark") "\
495 The value of this entry should be a number.
496 Any articles with a score lower than this number will be marked as read.")
498 (expunge (number :tag "Expunge") "\
499 The value of this entry should be a number.
500 Any articles with a score lower than this number will be removed from
501 the summary buffer.")
503 (mark-and-expunge (number :tag "Mark-and-expunge") "\
504 The value of this entry should be a number.
505 Any articles with a score lower than this number will be marked as
506 read and removed from the summary buffer.")
508 (thread-mark-and-expunge (number :tag "Thread-mark-and-expunge") "\
509 The value of this entry should be a number.
510 All articles that belong to a thread that has a total score below this
511 number will be marked as read and removed from the summary buffer.
512 `gnus-thread-score-function' says how to compute the total score
515 (files (repeat :inline t :tag "Files" file) "\
516 The value of this entry should be any number of file names.
517 These files are assumed to be score files as well, and will be loaded
518 the same way this one was.")
520 (exclude-files (repeat :inline t :tag "Exclude-files" file) "\
521 The clue of this entry should be any number of files.
522 These files will not be loaded, even though they would normally be so,
523 for some reason or other.")
525 (eval (sexp :tag "Eval" :value nil) "\
526 The value of this entry will be `eval'el.
527 This element will be ignored when handling global score files.")
529 (read-only (boolean :tag "Read-only" :value t) "\
530 Read-only score files will not be updated or saved.
531 Global score files should feature this atom.")
533 (orphan (number :tag "Orphan") "\
534 The value of this entry should be a number.
535 Articles that do not have parents will get this number added to their
536 scores. Imagine you follow some high-volume newsgroup, like
537 `comp.lang.c'. Most likely you will only follow a few of the threads,
538 also want to see any new threads.
540 You can do this with the following two score file entries:
543 (mark-and-expunge -100)
545 When you enter the group the first time, you will only see the new
546 threads. You then raise the score of the threads that you find
547 interesting (with `I T' or `I S'), and ignore (`C y') the rest.
548 Next time you enter the group, you will see new articles in the
549 interesting threads, plus any new threads.
551 I.e.---the orphan score atom is for high-volume groups where there
552 exist a few interesting threads which can't be found automatically
553 by ordinary scoring rules.")
555 (adapt (choice :tag "Adapt"
559 :hide-front-space t)) "\
560 This entry controls the adaptive scoring.
561 If it is t, the default adaptive scoring rules will be used. If it
562 is `ignore', no adaptive scoring will be performed on this group. If
563 it is a list, this list will be used as the adaptive scoring rules.
564 If it isn't present, or is something other than t or `ignore', the
565 default adaptive scoring rules will be used. If you want to use
566 adaptive scoring on most groups, you'd set `gnus-use-adaptive-scoring'
567 to t, and insert an `(adapt ignore)' in the groups where you do not
568 want adaptive scoring. If you only want adaptive scoring in a few
569 groups, you'd set `gnus-use-adaptive-scoring' to nil, and insert
570 `(adapt t)' in the score files of the groups where you want it.")
572 (adapt-file (file :tag "Adapt-file") "\
573 All adaptive score entries will go to the file named by this entry.
574 It will also be applied when entering the group. This atom might
575 be handy if you want to adapt on several groups at once, using the
576 same adaptive file for a number of groups.")
578 (local (repeat :tag "Local"
579 (group :value (nil nil)
580 (symbol :tag "Variable")
581 (sexp :tag "Value"))) "\
582 The value of this entry should be a list of `(VAR VALUE)' pairs.
583 Each VAR will be made buffer-local to the current summary buffer,
584 and set to the value specified. This is a convenient, if somewhat
585 strange, way of setting variables in some groups if you don't like
587 (touched (sexp :format "Touched\n") "Internal variable."))
588 "Alist of valid symbolic score parameters.
590 Each entry has the form (NAME TYPE DOC), where NAME is the parameter
591 itself (a symbol), TYPE is the parameters type (a sexp widget), and DOC is a
592 documentation string for the parameter.")
594 (define-widget 'gnus-score-string 'group
595 "Edit score entries for string-valued headers."
596 :convert-widget 'gnus-score-string-convert)
598 (defun gnus-score-string-convert (widget)
599 ;; Set args appropriately.
600 (let* ((tag (widget-get widget :tag))
601 (item `(const :format "" :value ,(downcase tag)))
602 (match '(string :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"
613 ;; I should really create a forgiving :match
614 ;; function for each type below, that only
615 ;; looked at the first letter.
616 (const :tag "Regexp" r)
617 (const :tag "Regexp (fixed case)" R)
618 (const :tag "Substring" s)
619 (const :tag "Substring (fixed case)" S)
620 (const :tag "Exact" e)
621 (const :tag "Exact (fixed case)" E)
622 (const :tag "Word" w)
623 (const :tag "Word (fixed case)" W)
624 (const :tag "default" nil)))
625 (group `(group ,match ,score ,expire ,type))
626 (doc (concat (or (widget-get widget :doc)
627 (concat "Change score based on the " tag
630 You can have an arbitrary number of score entries for this header,
631 each score entry has four elements:
633 1. The \"match element\". This should be the string to look for in the
636 2. The \"score element\". This number should be an integer in the
637 neginf to posinf interval. This number is added to the score
638 of the article if the match is successful. If this element is
639 not present, the `gnus-score-interactive-default-score' number
640 will be used instead. This is 1000 by default.
642 3. The \"date element\". This date says when the last time this score
643 entry matched, which provides a mechanism for expiring the
644 score entries. It this element is not present, the score
645 entry is permanent. The date is represented by the number of
646 days since December 31, 1 ce.
648 4. The \"type element\". This element specifies what function should
649 be used to see whether this score entry matches the article.
651 There are the regexp, as well as substring types, and exact match,
652 and word match types. If this element is not present, Gnus will
653 assume that substring matching should be used. There is case
654 sensitive variants of all match types.")))
655 (widget-put widget :args `(,item
660 :format "%t:\n%h%v%i\n\n"
662 :value ("" nil nil s)
667 (define-widget 'gnus-score-integer 'group
668 "Edit score entries for integer-valued headers."
669 :convert-widget 'gnus-score-integer-convert)
671 (defun gnus-score-integer-convert (widget)
672 ;; Set args appropriately.
673 (let* ((tag (widget-get widget :tag))
674 (item `(const :format "" :value ,(downcase tag)))
675 (match '(integer :tag "Match"))
676 (score '(choice :tag "Score"
677 (const :tag "default" nil)
678 (integer :format "%v"
679 :hide-front-space t)))
680 (expire '(choice :tag "Expire"
681 (const :tag "off" nil)
682 (integer :format "%v"
683 :hide-front-space t)))
684 (type '(choice :tag "Type"
691 (group `(group ,match ,score ,expire ,type))
692 (doc (concat (or (widget-get widget :doc)
693 (concat "Change score based on the " tag
695 (widget-put widget :args `(,item
700 :format "%t:\n%h%v%i\n\n"
704 (define-widget 'gnus-score-date 'group
705 "Edit score entries for date-valued headers."
706 :convert-widget 'gnus-score-date-convert)
708 (defun gnus-score-date-convert (widget)
709 ;; Set args appropriately.
710 (let* ((tag (widget-get widget :tag))
711 (item `(const :format "" :value ,(downcase tag)))
712 (match '(string :tag "Match"))
713 (score '(choice :tag "Score"
714 (const :tag "default" nil)
715 (integer :format "%v"
716 :hide-front-space t)))
717 (expire '(choice :tag "Expire"
718 (const :tag "off" nil)
719 (integer :format "%v"
720 :hide-front-space t)))
721 (type '(choice :tag "Type"
727 (group `(group ,match ,score ,expire ,type))
728 (doc (concat (or (widget-get widget :doc)
729 (concat "Change score based on the " tag
732 For the Date header we have three kinda silly match types: `before',
733 `at' and `after'. I can't really imagine this ever being useful, but,
734 like, it would feel kinda silly not to provide this function. Just in
735 case. You never know. Better safe than sorry. Once burnt, twice
736 shy. Don't judge a book by its cover. Never not have sex on a first
737 date. (I have been told that at least one person, and I quote,
738 \"found this function indispensable\", however.)
740 A more useful match type is `regexp'. With it, you can match the date
741 string using a regular expression. The date is normalized to ISO8601
742 compact format first---`YYYYMMDDTHHMMSS'. If you want to match all
743 articles that have been posted on April 1st in every year, you could
744 use `....0401.........' as a match string, for instance. (Note that
745 the date is kept in its original time zone, so this will match
746 articles that were posted when it was April 1st where the article was
747 posted from. Time zones are such wholesome fun for the whole family,
749 (widget-put widget :args `(,item
754 :format "%t:\n%h%v%i\n\n"
758 (defvar gnus-custom-scores)
759 (defvar gnus-custom-score-alist)
761 (defun gnus-score-customize (file)
762 "Customize score file FILE.
763 When called interactively, FILE defaults to the current score file.
764 This can be changed using the `\\[gnus-score-change-score-file]' command."
765 (interactive (list gnus-current-score-file))
767 (error (format "No score file for %s"
768 (gnus-group-decoded-name gnus-newsgroup-name))))
769 (let ((scores (gnus-score-load file))
770 (types (mapcar (lambda (entry)
771 `(group :format "%v%h\n"
773 (const :format "" ,(nth 0 entry))
775 gnus-score-parameters)))
777 (kill-buffer (gnus-get-buffer-create "*Gnus Customize*"))
778 (switch-to-buffer (gnus-get-buffer-create "*Gnus Customize*"))
780 (make-local-variable 'gnus-custom-score-alist)
781 (setq gnus-custom-score-alist scores)
782 (widget-insert "Customize the ")
783 (widget-create 'info-link
784 :help-echo "Push me to learn more."
786 "(gnus)Score File Format")
787 (widget-insert " for\n\t")
789 (widget-insert "\nand press ")
790 (widget-create 'push-button
792 :help-echo "Push me when done customizing."
793 :action 'gnus-score-customize-done)
795 Check the [ ] for the entries you want to apply to this score file, then
796 edit the value to suit your taste. Don't forget to mark the checkbox,
797 if you do all your changes will be lost. ")
798 (widget-create 'push-button
799 :action (lambda (&rest ignore)
800 (require 'gnus-audio)
801 (gnus-audio-play "Evil_Laugh.au"))
803 (widget-insert "\n\n")
804 (make-local-variable 'gnus-custom-scores)
805 (setq gnus-custom-scores
806 (widget-create 'group
808 `(checklist :inline t
810 (gnus-score-string :tag "From")
811 (gnus-score-string :tag "Subject")
812 (gnus-score-string :tag "References")
813 (gnus-score-string :tag "Xref")
814 (gnus-score-string :tag "Extra")
815 (gnus-score-string :tag "Message-ID")
816 (gnus-score-integer :tag "Lines")
817 (gnus-score-integer :tag "Chars")
818 (gnus-score-date :tag "Date")
819 (gnus-score-string :tag "Head"
821 Match all headers in the article.
823 Using one of `Head', `Body', `All' will slow down scoring considerable.
825 (gnus-score-string :tag "Body"
827 Match the body sans header of the article.
829 Using one of `Head', `Body', `All' will slow down scoring considerable.
831 (gnus-score-string :tag "All"
833 Match the entire article, including both headers and body.
835 Using one of `Head', `Body', `All' will slow down scoring
838 (gnus-score-string :tag
841 Score all followups to the specified authors.
843 This entry is somewhat special, in that it will match the `From:'
844 header, and affect the score of not only the matching articles, but
845 also all followups to the matching articles. This allows you
846 e.g. increase the score of followups to your own articles, or decrease
847 the score of followups to the articles of some known trouble-maker.
849 (gnus-score-string :tag "Thread"
851 Add a score entry on all articles that are part of a thread.
853 This match key works along the same lines as the `Followup' match key.
854 If you say that you want to score on a (sub-)thread that is started by
855 an article with a `Message-ID' X, then you add a `thread' match. This
856 will add a new `thread' match for each article that has X in its
857 `References' header. (These new `thread' matches will use the
858 `Message-ID's of these matching articles.) This will ensure that you
859 can raise/lower the score of an entire thread, even though some
860 articles in the thread may not have complete `References' headers.
861 Note that using this may lead to undeterministic scores of the
862 articles in the thread.
866 :tag "Unknown entries"
868 (use-local-map widget-keymap)
871 (defun gnus-score-customize-done (&rest ignore)
872 "Reset the score alist with the present value."
873 (let ((alist gnus-custom-score-alist)
874 (value (widget-value gnus-custom-scores)))
875 (setcar alist (car value))
876 (setcdr alist (cdr value))
877 (gnus-score-set 'touched '(t) alist))
881 (defvar category-fields nil)
882 (defvar gnus-agent-cat-predicate nil)
883 (defvar gnus-agent-cat-score-file nil)
884 (defvar gnus-agent-cat-length-when-short nil)
885 (defvar gnus-agent-cat-length-when-long nil)
886 (defvar gnus-agent-cat-low-score nil)
887 (defvar gnus-agent-cat-high-score nil)
888 (defvar gnus-agent-cat-groups nil)
889 (defvar gnus-agent-cat-enable-expiration nil)
890 (defvar gnus-agent-cat-days-until-old nil)
891 (defvar gnus-agent-cat-name nil)
894 (defun gnus-trim-whitespace (s)
895 (when (string-match "\\`[ \n\t]+" s)
896 (setq s (substring s (match-end 0))))
897 (when (string-match "[ \n\t]+\\'" s)
898 (setq s (substring s 0 (match-beginning 0))))
901 (defmacro gnus-agent-cat-prepare-category-field (parameter)
902 (let* ((entry (assq parameter gnus-agent-parameters))
903 (field (nth 3 entry)))
904 `(let* ((type (copy-sequence
905 (nth 1 (assq ',parameter gnus-agent-parameters))))
907 (deflt (if (,field defaults)
908 (concat " [" (gnus-trim-whitespace
909 (pp-to-string (,field defaults))) "]"))))
911 (if (eq (car type) 'radio)
912 (let* ((rtype (nreverse type))
914 (while (listp (or (cadr rt) 'not-list))
917 (setcdr rt (cons '(const :format "Inherit " nil) (cdr rt)))
918 (setq type (nreverse rtype))))
921 (let ((tag (cdr (memq :tag type))))
922 (if (string-match "\n" deflt)
923 (progn (while (progn (setq deflt (replace-match "\n " t t
925 (string-match "\n" deflt (match-end 0))))
926 (setq deflt (concat "\n" deflt))))
928 (setcar tag (concat (car tag) deflt))))
932 (set (make-local-variable ',field)
934 (widget-create type :value val)
935 (widget-create type)))
936 (widget-put ,field :default val)
937 (widget-put ,field :accessor ',field)
938 (push ,field category-fields))))
940 (defun gnus-agent-customize-category (category)
942 (interactive (list (gnus-category-name)))
943 (let ((info (assq category gnus-category-alist))
944 (defaults (list nil '(agent-predicate . false)
945 (cons 'agent-enable-expiration
946 gnus-agent-enable-expiration)
947 '(agent-days-until-old . 7)
948 (cons 'agent-length-when-short
949 gnus-agent-short-article)
950 (cons 'agent-length-when-long gnus-agent-long-article)
951 (cons 'agent-low-score gnus-agent-low-score)
952 (cons 'agent-high-score gnus-agent-high-score))))
954 (let ((old (get-buffer "*Gnus Agent Category Customize*")))
956 (gnus-kill-buffer old)))
957 (switch-to-buffer (gnus-get-buffer-create
958 "*Gnus Agent Category Customize*"))
960 (let ((inhibit-read-only t))
962 (buffer-disable-undo)
964 (let* ((name (gnus-agent-cat-name info)))
965 (widget-insert "Customize the Agent Category '")
966 (widget-insert (symbol-name name))
967 (widget-insert "' and press ")
971 '(lambda (&rest ignore)
972 (let* ((info (assq gnus-agent-cat-name gnus-category-alist))
973 (widgets category-fields))
975 (let* ((widget (pop widgets))
976 (value (ignore-errors (widget-value widget))))
977 (eval `(setf (,(widget-get widget :accessor) ',info)
979 (gnus-category-write)
980 (gnus-kill-buffer (current-buffer))
981 (when (get-buffer gnus-category-buffer)
982 (switch-to-buffer (get-buffer gnus-category-buffer))
983 (gnus-category-list)))
986 "\n Note: Empty fields default to the customizable global\
989 (set (make-local-variable 'gnus-agent-cat-name)
992 (set (make-local-variable 'category-fields) nil)
993 (gnus-agent-cat-prepare-category-field agent-predicate)
995 (gnus-agent-cat-prepare-category-field agent-score)
996 (gnus-agent-cat-prepare-category-field agent-short-article)
997 (gnus-agent-cat-prepare-category-field agent-long-article)
998 (gnus-agent-cat-prepare-category-field agent-low-score)
999 (gnus-agent-cat-prepare-category-field agent-high-score)
1001 ;; The group list is NOT handled with
1002 ;; gnus-agent-cat-prepare-category-field as I don't want the
1003 ;; group list to appear when customizing a topic.
1004 (widget-insert "\n")
1005 (set (make-local-variable 'gnus-agent-cat-groups)
1008 :format "%[Select Member Groups%]\n%v" :value ignore
1009 (const :menu-tag "do not change" :tag "" :value ignore)
1010 (checklist :entry-format "%b %v"
1011 :menu-tag "display group selectors"
1017 (gnus-info-group newsrc)
1018 (gnus-agent-cat-groups info))))
1019 (cdr gnus-newsrc-alist)))
1020 ,@(mapcar (lambda (newsrc)
1021 `(const ,(gnus-info-group newsrc)))
1022 (cdr gnus-newsrc-alist))))))
1024 (widget-put gnus-agent-cat-groups :default (gnus-agent-cat-groups info))
1025 (widget-put gnus-agent-cat-groups :accessor 'gnus-agent-cat-groups)
1026 (push gnus-agent-cat-groups category-fields)
1028 (widget-insert "\nExpiration Settings ")
1030 (gnus-agent-cat-prepare-category-field agent-enable-expiration)
1031 (gnus-agent-cat-prepare-category-field agent-days-until-old)
1033 (use-local-map widget-keymap)
1035 (buffer-enable-undo))))
1041 ;;; gnus-cus.el ends here