1 ;;; gnus-cus.el --- customization commands for Gnus
3 ;; Copyright (C) 1996, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008 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 3, 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., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, 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-mode-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 in it.")
210 (choice :tag
"Highlight words"
212 (repeat (list (regexp :tag
"Highlight regexp")
213 (number :tag
"Group for entire word" 0)
214 (number :tag
"Group for displayed part" 0)
216 gnus-emphasis-highlight-words
))))
218 See `gnus-emphasis-alist'.")
221 (choice :tag
"Posting style"
227 (const signature-file
)
234 (string :tag
"Header"))
235 (string :format
"%v"))))
237 See `gnus-posting-styles'."))
238 "Alist of valid group or topic parameters.
240 Each entry has the form (NAME TYPE DOC), where NAME is the parameter
241 itself (a symbol), TYPE is the parameters type (a sexp widget), and
242 DOC is a documentation string for the parameter.")
244 (defconst gnus-extra-topic-parameters
245 '((subscribe (regexp :tag
"Subscribe") "\
246 If `gnus-subscribe-newsgroup-method' or
247 `gnus-subscribe-options-newsgroup-method' is set to
248 `gnus-subscribe-topics', new groups that matches this regexp will
249 automatically be subscribed to this topic")
250 (subscribe-level (integer :tag
"Subscribe Level" :value
1) "\
251 If this topic parameter is set, when new groups are subscribed
252 automatically under this topic (via the `subscribe' topic parameter)
253 assign this level to the group, rather than the default level
254 set in `gnus-level-default-subscribed'"))
255 "Alist of topic parameters that are not also group parameters.
257 Each entry has the form (NAME TYPE DOC), where NAME is the parameter
258 itself (a symbol), TYPE is the parameters type (a sexp widget), and
259 DOC is a documentation string for the parameter.")
261 (defconst gnus-extra-group-parameters
262 '((uidvalidity (string :tag
"IMAP uidvalidity") "\
263 Server-assigned value attached to IMAP groups, used to maintain consistency."))
264 "Alist of group parameters that are not also topic parameters.
266 Each entry has the form (NAME TYPE DOC), where NAME is the parameter
267 itself (a symbol), TYPE is the parameters type (a sexp widget), and
268 DOC is a documentation string for the parameter.")
271 (defconst gnus-agent-parameters
273 (sexp :tag
"Selection Predicate" :value false
)
274 "Predicate used to automatically select articles for downloading."
275 gnus-agent-cat-predicate
)
277 (choice :tag
"Score File" :value nil
278 (const file
:tag
"Use group's score files")
279 (repeat (list (string :format
"%v" :tag
"File name"))))
280 "Which score files to use when using score to select articles to fetch.
283 All articles will be scored to zero (0).
286 The group's score files will be used to score the articles.
289 A list of score file names."
290 gnus-agent-cat-score-file
)
292 (integer :tag
"Max Length of Short Article" :value
"")
293 "The SHORT predicate will evaluate to true when the article is
294 shorter than this length." gnus-agent-cat-length-when-short
)
296 (integer :tag
"Min Length of Long Article" :value
"")
297 "The LONG predicate will evaluate to true when the article is
298 longer than this length." gnus-agent-cat-length-when-long
)
300 (integer :tag
"Low Score Limit" :value
"")
301 "The LOW predicate will evaluate to true when the article scores
302 lower than this limit." gnus-agent-cat-low-score
)
304 (integer :tag
"High Score Limit" :value
"")
305 "The HIGH predicate will evaluate to true when the article scores
306 higher than this limit." gnus-agent-cat-high-score
)
307 (agent-days-until-old
308 (integer :tag
"Days Until Old" :value
"")
309 "The OLD predicate will evaluate to true when the fetched article
310 has been stored locally for at least this many days."
311 gnus-agent-cat-days-until-old
)
312 (agent-enable-expiration
313 (radio :tag
"Expire in this Group or Topic" :value 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 (agent-enable-undownloaded-faces
319 (boolean :tag
"Enable Agent Faces")
320 "Have the summary buffer use the agent's undownloaded faces.
321 These faces, when enabled, act as a warning that an article has not
322 been fetched into either the agent nor the cache. This is of most use
323 to users who use the agent as a cache (i.e. they only operate on
324 articles that have been downloaded). Leave disabled to display normal
325 article faces even when the article hasn't been downloaded."
326 gnus-agent-cat-enable-undownloaded-faces
))
327 "Alist of group parameters that are not also topic parameters.
329 Each entry has the form (NAME TYPE DOC ACCESSOR), where NAME is the
330 parameter itself (a symbol), TYPE is the parameters type (a sexp
331 widget), DOC is a documentation string for the parameter, and ACCESSOR
332 is a function (symbol) that extracts the current value from the
335 (defvar gnus-custom-params
)
336 (defvar gnus-custom-method
)
337 (defvar gnus-custom-group
)
338 (defvar gnus-custom-topic
)
340 (defun gnus-group-customize (group &optional topic
)
341 "Edit the group or topic on the current line."
342 (interactive (list (gnus-group-group-name) (gnus-group-topic-name)))
344 (types (mapcar (lambda (entry)
345 `(cons :format
"%v%h\n"
347 (const :format
"" ,(nth 0 entry
))
349 (append (reverse gnus-group-parameters-more
)
350 gnus-group-parameters
352 gnus-extra-group-parameters
353 gnus-extra-topic-parameters
))))
354 (agent (mapcar (lambda (entry)
355 (let ((type (nth 1 entry
))
358 (setq type
(copy-sequence type
)))
360 (setq vcons
(cdr (memq :value type
)))
362 (if (symbolp (car vcons
))
364 (setcar vcons
(symbol-value (car vcons
)))
366 `(cons :format
"%v%h\n"
368 (const :format
"" ,(nth 0 entry
))
371 gnus-agent-parameters
))))
372 (unless (or group topic
)
373 (error "No group on current line"))
374 (when (and group topic
)
375 (error "Both a group an topic on current line"))
376 (unless (or topic
(setq info
(gnus-get-info group
)))
377 (error "Killed group; can't be edited"))
379 (gnus-kill-buffer (gnus-get-buffer-create "*Gnus Customize*"))
380 (switch-to-buffer (gnus-get-buffer-create "*Gnus Customize*"))
382 (make-local-variable 'gnus-custom-group
)
383 (setq gnus-custom-group group
)
384 (make-local-variable 'gnus-custom-topic
)
385 (setq gnus-custom-topic topic
)
386 (buffer-disable-undo)
387 (widget-insert "Customize the ")
389 (widget-create 'info-link
390 :help-echo
"Push me to learn more."
391 :tag
"group parameters"
392 "(gnus)Group Parameters")
393 (widget-create 'info-link
394 :help-echo
"Push me to learn more."
395 :tag
"topic parameters"
396 "(gnus)Topic Parameters"))
397 (widget-insert " for <")
398 (widget-insert (gnus-group-decoded-name (or group topic
)))
399 (widget-insert "> and press ")
400 (widget-create 'push-button
402 :help-echo
"Push me when done customizing."
403 :action
'gnus-group-customize-done
)
404 (widget-insert ".\n\n")
405 (make-local-variable 'gnus-custom-params
)
407 (let ((values (if group
408 (gnus-info-params info
)
409 (gnus-topic-parameters topic
))))
411 ;; The parameters in values may contain duplicates. This is
412 ;; normally OK as assq returns the first. However, right here
413 ;; every duplicate ends up being displayed. So, rather than
414 ;; display them, remove them from the list.
416 (let ((tmp (setq values
(gnus-copy-sequence values
)))
419 (while (setq elem
(assq (caar tmp
) (cdr tmp
)))
421 (setq tmp
(cdr tmp
))))
423 (setq gnus-custom-params
424 (apply 'widget-create
'group
427 (list `(set :inline t
432 These special parameters are recognized by Gnus.
433 Check the [ ] for the parameters you want to apply to this group or
434 to the groups in this topic, then edit the value to suit your taste."
439 :tag
"Agent Parameters"
441 :doc
"\ These agent parameters are
442 recognized by Gnus. They control article selection and expiration for
443 use in the unplugged cache. Check the [ ] for the parameters you want
444 to apply to this group or to the groups in this topic, then edit the
445 value to suit your taste.
447 For those interested, group parameters override topic parameters while
448 topic parameters override agent category parameters. Underlying
449 category parameters are the customizable variables." ,@agent
))
452 :format
"%t:\n%h%v%i\n\n"
454 Set variables local to the group you are entering.
456 If you want to turn threading off in `news.answers', you could put
457 `(gnus-show-threads nil)' in the group parameters of that group.
458 `gnus-show-threads' will be made into a local variable in the summary
459 buffer you enter, and the form nil will be `eval'ed there.
461 This can also be used as a group-specific hook function, if you'd
462 like. If you want to hear a beep when you enter a group, you could
463 put something like `(dummy-variable (ding))' in the parameters of that
464 group. `dummy-variable' will be set to the result of the `(ding)'
465 form, but who cares?"
466 (list :format
"%v" :value
(nil nil
)
467 (symbol :tag
"Variable")
472 :tag
"Unknown entries"
475 (widget-insert "\n\nYou can also edit the ")
476 (widget-create 'info-link
478 :help-echo
"Push me to learn more about select methods."
479 "(gnus)Select Methods")
480 (widget-insert " for the group.\n")
481 (setq gnus-custom-method
484 :value
(gnus-info-method info
))))
485 (use-local-map widget-keymap
)
488 (goto-char (point-min))))
490 (defun gnus-group-customize-done (&rest ignore
)
491 "Apply changes and bury the buffer."
493 (if gnus-custom-topic
494 (gnus-topic-set-parameters gnus-custom-topic
495 (widget-value gnus-custom-params
))
496 (gnus-group-edit-group-done 'params gnus-custom-group
497 (widget-value gnus-custom-params
))
498 (gnus-group-edit-group-done 'method gnus-custom-group
499 (widget-value gnus-custom-method
)))
502 ;;; Score Customization:
504 (defconst gnus-score-parameters
505 '((mark (number :tag
"Mark") "\
506 The value of this entry should be a number.
507 Any articles with a score lower than this number will be marked as read.")
509 (expunge (number :tag
"Expunge") "\
510 The value of this entry should be a number.
511 Any articles with a score lower than this number will be removed from
512 the summary buffer.")
514 (mark-and-expunge (number :tag
"Mark-and-expunge") "\
515 The value of this entry should be a number.
516 Any articles with a score lower than this number will be marked as
517 read and removed from the summary buffer.")
519 (thread-mark-and-expunge (number :tag
"Thread-mark-and-expunge") "\
520 The value of this entry should be a number.
521 All articles that belong to a thread that has a total score below this
522 number will be marked as read and removed from the summary buffer.
523 `gnus-thread-score-function' says how to compute the total score
526 (files (repeat :inline t
:tag
"Files" file
) "\
527 The value of this entry should be any number of file names.
528 These files are assumed to be score files as well, and will be loaded
529 the same way this one was.")
531 (exclude-files (repeat :inline t
:tag
"Exclude-files" file
) "\
532 The clue of this entry should be any number of files.
533 These files will not be loaded, even though they would normally be so,
534 for some reason or other.")
536 (eval (sexp :tag
"Eval" :value nil
) "\
537 The value of this entry will be `eval'el.
538 This element will be ignored when handling global score files.")
540 (read-only (boolean :tag
"Read-only" :value t
) "\
541 Read-only score files will not be updated or saved.
542 Global score files should feature this atom.")
544 (orphan (number :tag
"Orphan") "\
545 The value of this entry should be a number.
546 Articles that do not have parents will get this number added to their
547 scores. Imagine you follow some high-volume newsgroup, like
548 `comp.lang.c'. Most likely you will only follow a few of the threads,
549 also want to see any new threads.
551 You can do this with the following two score file entries:
554 (mark-and-expunge -100)
556 When you enter the group the first time, you will only see the new
557 threads. You then raise the score of the threads that you find
558 interesting (with `I T' or `I S'), and ignore (`C y') the rest.
559 Next time you enter the group, you will see new articles in the
560 interesting threads, plus any new threads.
562 I.e.---the orphan score atom is for high-volume groups where there
563 exist a few interesting threads which can't be found automatically
564 by ordinary scoring rules.")
566 (adapt (choice :tag
"Adapt"
570 :hide-front-space t
)) "\
571 This entry controls the adaptive scoring.
572 If it is t, the default adaptive scoring rules will be used. If it
573 is `ignore', no adaptive scoring will be performed on this group. If
574 it is a list, this list will be used as the adaptive scoring rules.
575 If it isn't present, or is something other than t or `ignore', the
576 default adaptive scoring rules will be used. If you want to use
577 adaptive scoring on most groups, you'd set `gnus-use-adaptive-scoring'
578 to t, and insert an `(adapt ignore)' in the groups where you do not
579 want adaptive scoring. If you only want adaptive scoring in a few
580 groups, you'd set `gnus-use-adaptive-scoring' to nil, and insert
581 `(adapt t)' in the score files of the groups where you want it.")
583 (adapt-file (file :tag
"Adapt-file") "\
584 All adaptive score entries will go to the file named by this entry.
585 It will also be applied when entering the group. This atom might
586 be handy if you want to adapt on several groups at once, using the
587 same adaptive file for a number of groups.")
589 (local (repeat :tag
"Local"
590 (group :value
(nil nil
)
591 (symbol :tag
"Variable")
592 (sexp :tag
"Value"))) "\
593 The value of this entry should be a list of `(VAR VALUE)' pairs.
594 Each VAR will be made buffer-local to the current summary buffer,
595 and set to the value specified. This is a convenient, if somewhat
596 strange, way of setting variables in some groups if you don't like
598 (touched (sexp :format
"Touched\n") "Internal variable."))
599 "Alist of valid symbolic score parameters.
601 Each entry has the form (NAME TYPE DOC), where NAME is the parameter
602 itself (a symbol), TYPE is the parameters type (a sexp widget), and DOC is a
603 documentation string for the parameter.")
605 (define-widget 'gnus-score-string
'group
606 "Edit score entries for string-valued headers."
607 :convert-widget
'gnus-score-string-convert
)
609 (defun gnus-score-string-convert (widget)
610 ;; Set args appropriately.
611 (let* ((tag (widget-get widget
:tag
))
612 (item `(const :format
"" :value
,(downcase tag
)))
613 (match '(string :tag
"Match"))
614 (score '(choice :tag
"Score"
615 (const :tag
"default" nil
)
616 (integer :format
"%v"
617 :hide-front-space t
)))
618 (expire '(choice :tag
"Expire"
619 (const :tag
"off" nil
)
620 (integer :format
"%v"
621 :hide-front-space t
)))
622 (type '(choice :tag
"Type"
624 ;; I should really create a forgiving :match
625 ;; function for each type below, that only
626 ;; looked at the first letter.
627 (const :tag
"Regexp" r
)
628 (const :tag
"Regexp (fixed case)" R
)
629 (const :tag
"Substring" s
)
630 (const :tag
"Substring (fixed case)" S
)
631 (const :tag
"Exact" e
)
632 (const :tag
"Exact (fixed case)" E
)
633 (const :tag
"Word" w
)
634 (const :tag
"Word (fixed case)" W
)
635 (const :tag
"default" nil
)))
636 (group `(group ,match
,score
,expire
,type
))
637 (doc (concat (or (widget-get widget
:doc
)
638 (concat "Change score based on the " tag
641 You can have an arbitrary number of score entries for this header,
642 each score entry has four elements:
644 1. The \"match element\". This should be the string to look for in the
647 2. The \"score element\". This number should be an integer in the
648 neginf to posinf interval. This number is added to the score
649 of the article if the match is successful. If this element is
650 not present, the `gnus-score-interactive-default-score' number
651 will be used instead. This is 1000 by default.
653 3. The \"date element\". This date says when the last time this score
654 entry matched, which provides a mechanism for expiring the
655 score entries. It this element is not present, the score
656 entry is permanent. The date is represented by the number of
657 days since December 31, 1 ce.
659 4. The \"type element\". This element specifies what function should
660 be used to see whether this score entry matches the article.
662 There are the regexp, as well as substring types, and exact match,
663 and word match types. If this element is not present, Gnus will
664 assume that substring matching should be used. There is case
665 sensitive variants of all match types.")))
666 (widget-put widget
:args
`(,item
671 :format
"%t:\n%h%v%i\n\n"
673 :value
("" nil nil s
)
678 (define-widget 'gnus-score-integer
'group
679 "Edit score entries for integer-valued headers."
680 :convert-widget
'gnus-score-integer-convert
)
682 (defun gnus-score-integer-convert (widget)
683 ;; Set args appropriately.
684 (let* ((tag (widget-get widget
:tag
))
685 (item `(const :format
"" :value
,(downcase tag
)))
686 (match '(integer :tag
"Match"))
687 (score '(choice :tag
"Score"
688 (const :tag
"default" nil
)
689 (integer :format
"%v"
690 :hide-front-space t
)))
691 (expire '(choice :tag
"Expire"
692 (const :tag
"off" nil
)
693 (integer :format
"%v"
694 :hide-front-space t
)))
695 (type '(choice :tag
"Type"
702 (group `(group ,match
,score
,expire
,type
))
703 (doc (concat (or (widget-get widget
:doc
)
704 (concat "Change score based on the " tag
706 (widget-put widget
:args
`(,item
711 :format
"%t:\n%h%v%i\n\n"
715 (define-widget 'gnus-score-date
'group
716 "Edit score entries for date-valued headers."
717 :convert-widget
'gnus-score-date-convert
)
719 (defun gnus-score-date-convert (widget)
720 ;; Set args appropriately.
721 (let* ((tag (widget-get widget
:tag
))
722 (item `(const :format
"" :value
,(downcase tag
)))
723 (match '(string :tag
"Match"))
724 (score '(choice :tag
"Score"
725 (const :tag
"default" nil
)
726 (integer :format
"%v"
727 :hide-front-space t
)))
728 (expire '(choice :tag
"Expire"
729 (const :tag
"off" nil
)
730 (integer :format
"%v"
731 :hide-front-space t
)))
732 (type '(choice :tag
"Type"
738 (group `(group ,match
,score
,expire
,type
))
739 (doc (concat (or (widget-get widget
:doc
)
740 (concat "Change score based on the " tag
743 For the Date header we have three kinda silly match types: `before',
744 `at' and `after'. I can't really imagine this ever being useful, but,
745 like, it would feel kinda silly not to provide this function. Just in
746 case. You never know. Better safe than sorry. Once burnt, twice
747 shy. Don't judge a book by its cover. Never not have sex on a first
748 date. (I have been told that at least one person, and I quote,
749 \"found this function indispensable\", however.)
751 A more useful match type is `regexp'. With it, you can match the date
752 string using a regular expression. The date is normalized to ISO8601
753 compact format first---`YYYYMMDDTHHMMSS'. If you want to match all
754 articles that have been posted on April 1st in every year, you could
755 use `....0401.........' as a match string, for instance. (Note that
756 the date is kept in its original time zone, so this will match
757 articles that were posted when it was April 1st where the article was
758 posted from. Time zones are such wholesome fun for the whole family,
760 (widget-put widget
:args
`(,item
765 :format
"%t:\n%h%v%i\n\n"
769 (define-widget 'gnus-score-extra
'group
770 "Edit score entries for extra headers."
771 :convert-widget
'gnus-score-extra-convert
)
773 (defun gnus-score-extra-convert (widget)
774 ;; Set args appropriately.
775 (let* ((tag (widget-get widget
:tag
))
776 (item `(const :format
"" :value
,(downcase tag
)))
777 (match '(string :tag
"Match"))
778 (score '(choice :tag
"Score"
779 (const :tag
"default" nil
)
780 (integer :format
"%v"
781 :hide-front-space t
)))
782 (expire '(choice :tag
"Expire"
783 (const :tag
"off" nil
)
784 (integer :format
"%v"
785 :hide-front-space t
)))
786 (type '(choice :tag
"Type"
788 ;; I should really create a forgiving :match
789 ;; function for each type below, that only
790 ;; looked at the first letter.
791 (const :tag
"Regexp" r
)
792 (const :tag
"Regexp (fixed case)" R
)
793 (const :tag
"Substring" s
)
794 (const :tag
"Substring (fixed case)" S
)
795 (const :tag
"Exact" e
)
796 (const :tag
"Exact (fixed case)" E
)
797 (const :tag
"Word" w
)
798 (const :tag
"Word (fixed case)" W
)
799 (const :tag
"default" nil
)))
800 (header (if gnus-extra-headers
802 `(choice :tag
"Header"
803 ,@(mapcar (lambda (h)
804 (setq name
(symbol-name h
))
805 (list 'const
:tag name name
))
807 (string :tag
"Other" :format
"%v")))
808 '(string :tag
"Header")))
809 (group `(group ,match
,score
,expire
,type
,header
))
810 (doc (concat (or (widget-get widget
:doc
)
811 (concat "Change score based on the " tag
820 :format
"%t:\n%h%v%i\n\n"
823 ,(if gnus-extra-headers
824 (symbol-name (car gnus-extra-headers
))
830 (defvar gnus-custom-scores
)
831 (defvar gnus-custom-score-alist
)
833 (defun gnus-score-customize (file)
834 "Customize score file FILE.
835 When called interactively, FILE defaults to the current score file.
836 This can be changed using the `\\[gnus-score-change-score-file]' command."
837 (interactive (list gnus-current-score-file
))
839 (error "No score file for %s"
840 (gnus-group-decoded-name gnus-newsgroup-name
)))
841 (let ((scores (gnus-score-load file
))
842 (types (mapcar (lambda (entry)
843 `(group :format
"%v%h\n"
845 (const :format
"" ,(nth 0 entry
))
847 gnus-score-parameters
)))
849 (kill-buffer (gnus-get-buffer-create "*Gnus Customize*"))
850 (switch-to-buffer (gnus-get-buffer-create "*Gnus Customize*"))
852 (make-local-variable 'gnus-custom-score-alist
)
853 (setq gnus-custom-score-alist scores
)
854 (widget-insert "Customize the ")
855 (widget-create 'info-link
856 :help-echo
"Push me to learn more."
858 "(gnus)Score File Format")
859 (widget-insert " for\n\t")
861 (widget-insert "\nand press ")
862 (widget-create 'push-button
864 :help-echo
"Push me when done customizing."
865 :action
'gnus-score-customize-done
)
867 Check the [ ] for the entries you want to apply to this score file, then
868 edit the value to suit your taste. Don't forget to mark the checkbox,
869 if you do all your changes will be lost. ")
870 (widget-create 'push-button
871 :action
(lambda (&rest ignore
)
872 (require 'gnus-audio
)
873 (gnus-audio-play "Evil_Laugh.au"))
875 (widget-insert "\n\n")
876 (make-local-variable 'gnus-custom-scores
)
877 (setq gnus-custom-scores
878 (widget-create 'group
880 `(checklist :inline t
882 (gnus-score-string :tag
"From")
883 (gnus-score-string :tag
"Subject")
884 (gnus-score-string :tag
"References")
885 (gnus-score-string :tag
"Xref")
886 (gnus-score-extra :tag
"Extra")
887 (gnus-score-string :tag
"Message-ID")
888 (gnus-score-integer :tag
"Lines")
889 (gnus-score-integer :tag
"Chars")
890 (gnus-score-date :tag
"Date")
891 (gnus-score-string :tag
"Head"
893 Match all headers in the article.
895 Using one of `Head', `Body', `All' will slow down scoring considerable.
897 (gnus-score-string :tag
"Body"
899 Match the body sans header of the article.
901 Using one of `Head', `Body', `All' will slow down scoring considerable.
903 (gnus-score-string :tag
"All"
905 Match the entire article, including both headers and body.
907 Using one of `Head', `Body', `All' will slow down scoring
910 (gnus-score-string :tag
913 Score all followups to the specified authors.
915 This entry is somewhat special, in that it will match the `From:'
916 header, and affect the score of not only the matching articles, but
917 also all followups to the matching articles. This allows you
918 e.g. increase the score of followups to your own articles, or decrease
919 the score of followups to the articles of some known trouble-maker.
921 (gnus-score-string :tag
"Thread"
923 Add a score entry on all articles that are part of a thread.
925 This match key works along the same lines as the `Followup' match key.
926 If you say that you want to score on a (sub-)thread that is started by
927 an article with a `Message-ID' X, then you add a `thread' match. This
928 will add a new `thread' match for each article that has X in its
929 `References' header. (These new `thread' matches will use the
930 `Message-ID's of these matching articles.) This will ensure that you
931 can raise/lower the score of an entire thread, even though some
932 articles in the thread may not have complete `References' headers.
933 Note that using this may lead to undeterministic scores of the
934 articles in the thread.
938 :tag
"Unknown entries"
940 (use-local-map widget-keymap
)
943 (defun gnus-score-customize-done (&rest ignore
)
944 "Reset the score alist with the present value."
945 (let ((alist gnus-custom-score-alist
)
946 (value (widget-value gnus-custom-scores
)))
947 (setcar alist
(car value
))
948 (setcdr alist
(cdr value
))
949 (gnus-score-set 'touched
'(t) alist
))
953 (defvar category-fields nil
)
954 (defvar gnus-agent-cat-name
)
955 (defvar gnus-agent-cat-score-file
)
956 (defvar gnus-agent-cat-length-when-short
)
957 (defvar gnus-agent-cat-length-when-long
)
958 (defvar gnus-agent-cat-low-score
)
959 (defvar gnus-agent-cat-high-score
)
960 (defvar gnus-agent-cat-enable-expiration
)
961 (defvar gnus-agent-cat-days-until-old
)
962 (defvar gnus-agent-cat-predicate
)
963 (defvar gnus-agent-cat-groups
)
964 (defvar gnus-agent-cat-enable-undownloaded-faces
)
967 (defun gnus-trim-whitespace (s)
968 (when (string-match "\\`[ \n\t]+" s
)
969 (setq s
(substring s
(match-end 0))))
970 (when (string-match "[ \n\t]+\\'" s
)
971 (setq s
(substring s
0 (match-beginning 0))))
974 (defmacro gnus-agent-cat-prepare-category-field
(parameter)
975 (let* ((entry (assq parameter gnus-agent-parameters
))
976 (field (nth 3 entry
)))
977 `(let* ((type (copy-sequence
978 (nth 1 (assq ',parameter gnus-agent-parameters
))))
980 (deflt (if (,field defaults
)
981 (concat " [" (gnus-trim-whitespace
982 (gnus-pp-to-string (,field defaults
)))
986 (if (eq (car type
) 'radio
)
987 (let* ((rtype (nreverse type
))
989 (while (listp (or (cadr rt
) 'not-list
))
992 (setcdr rt
(cons '(const :format
"Inherit " nil
) (cdr rt
)))
993 (setq type
(nreverse rtype
))))
996 (let ((tag (cdr (memq :tag type
))))
997 (when (string-match "\n" deflt
)
998 (while (progn (setq deflt
(replace-match "\n " t t
1000 (string-match "\n" deflt
(match-end 0))))
1001 (setq deflt
(concat "\n" deflt
)))
1003 (setcar tag
(concat (car tag
) deflt
))))
1005 (widget-insert "\n")
1008 (widget-create type
:value val
)
1009 (widget-create type
))
1010 symb
(set (make-local-variable ',field
) val
))
1012 (widget-put symb
:default val
)
1013 (widget-put symb
:accessor
',field
)
1014 (push symb category-fields
))))
1016 (defun gnus-agent-customize-category (category)
1017 "Edit the CATEGORY."
1018 (interactive (list (gnus-category-name)))
1019 (let ((info (assq category gnus-category-alist
))
1020 (defaults (list nil
'(agent-predicate . false
)
1021 (cons 'agent-enable-expiration
1022 gnus-agent-enable-expiration
)
1023 '(agent-days-until-old .
7)
1024 (cons 'agent-length-when-short
1025 gnus-agent-short-article
)
1026 (cons 'agent-length-when-long gnus-agent-long-article
)
1027 (cons 'agent-low-score gnus-agent-low-score
)
1028 (cons 'agent-high-score gnus-agent-high-score
))))
1030 (let ((old (get-buffer "*Gnus Agent Category Customize*")))
1032 (gnus-kill-buffer old
)))
1033 (switch-to-buffer (gnus-get-buffer-create
1034 "*Gnus Agent Category Customize*"))
1036 (let ((inhibit-read-only t
))
1038 (buffer-disable-undo)
1040 (let* ((name (gnus-agent-cat-name info
)))
1041 (widget-insert "Customize the Agent Category '")
1042 (widget-insert (symbol-name name
))
1043 (widget-insert "' and press ")
1047 '(lambda (&rest ignore
)
1048 (let* ((info (assq gnus-agent-cat-name gnus-category-alist
))
1049 (widgets category-fields
))
1051 (let* ((widget (pop widgets
))
1052 (value (condition-case nil
(widget-value widget
) (error))))
1053 (eval `(setf (,(widget-get widget
:accessor
) ',info
)
1055 (gnus-category-write)
1056 (gnus-kill-buffer (current-buffer))
1057 (when (get-buffer gnus-category-buffer
)
1058 (switch-to-buffer (get-buffer gnus-category-buffer
))
1059 (gnus-category-list)))
1062 "\n Note: Empty fields default to the customizable global\
1065 (set (make-local-variable 'gnus-agent-cat-name
)
1068 (set (make-local-variable 'category-fields
) nil
)
1069 (gnus-agent-cat-prepare-category-field agent-predicate
)
1071 (gnus-agent-cat-prepare-category-field agent-score
)
1072 (gnus-agent-cat-prepare-category-field agent-short-article
)
1073 (gnus-agent-cat-prepare-category-field agent-long-article
)
1074 (gnus-agent-cat-prepare-category-field agent-low-score
)
1075 (gnus-agent-cat-prepare-category-field agent-high-score
)
1077 ;; The group list is NOT handled with
1078 ;; gnus-agent-cat-prepare-category-field as I don't want the
1079 ;; group list to appear when customizing a topic.
1080 (widget-insert "\n")
1084 (make-local-variable 'gnus-agent-cat-groups
)
1087 :format
"%[Select Member Groups%]\n%v" :value ignore
1088 (const :menu-tag
"do not change" :tag
"" :value ignore
)
1089 (checklist :entry-format
"%b %v"
1090 :menu-tag
"display group selectors"
1097 (gnus-info-group newsrc
)
1098 (gnus-agent-cat-groups info
))))
1099 (cdr gnus-newsrc-alist
)))
1100 ,@(mapcar (lambda (newsrc)
1101 `(const ,(gnus-info-group newsrc
)))
1102 (cdr gnus-newsrc-alist
))))))))
1104 (widget-put symb
:default
(gnus-agent-cat-groups info
))
1105 (widget-put symb
:accessor
'gnus-agent-cat-groups
)
1106 (push symb category-fields
))
1108 (widget-insert "\nExpiration Settings ")
1110 (gnus-agent-cat-prepare-category-field agent-enable-expiration
)
1111 (gnus-agent-cat-prepare-category-field agent-days-until-old
)
1113 (widget-insert "\nVisual Settings ")
1115 (gnus-agent-cat-prepare-category-field agent-enable-undownloaded-faces
)
1117 (use-local-map widget-keymap
)
1119 (buffer-enable-undo))))
1125 ;;; arch-tag: a37c285a-49bc-4235-8244-804536effeaf
1126 ;;; gnus-cus.el ends here