1 ;;; gnus-edit.el --- Gnus SCORE file editing
2 ;; Copyright (C) 1995,96 Free Software Foundation, Inc.
4 ;; Author: Per Abrahamsen <abraham@iesd.auc.dk>
5 ;; Keywords: news, help
10 ;; Type `M-x gnus-score-customize RET' to invoke.
16 (eval-when-compile (require 'cl
))
18 (defconst gnus-score-custom-data
20 (doc .
"Customization of Gnus SCORE files.
22 SCORE files allow you to assign a score to each article when you enter
23 a group, and automatically mark the articles as read or delete them
24 based on the score. In the summary buffer you can use the score to
25 sort the articles by score (`C-c C-s C-s') or to jump to the unread
26 article with the highest score (`,').")
30 (doc .
"Name of SCORE file to customize.
32 Enter the name in the `File' field, then push the [Load] button to
33 load it. When done editing, push the [Save] button to save the file.
35 Several score files may apply to each group, and several groups may
36 use the same score file. This is controlled implicitly by the name of
37 the score file and the value of the global variable
38 `gnus-score-find-score-files-function', and explicitly by the the
39 `Files' and `Exclude Files' entries.")
44 (query . gnus-score-custom-load
))
47 (query . gnus-score-custom-save
))
50 (directory . gnus-kill-files-directory
)
51 (default-file .
"SCORE")
56 List of score files to load when the the current score file is loaded.
57 You can use this to share score entries between multiple score files.
59 Push the `[INS]' button add a score file to the list, or `[DEL]' to
60 delete a score file from the list.")
62 (data ((type . repeat
)
65 (directory . gnus-kill-files-directory
)))))
66 ((name . exclude-files
)
67 (tag .
"Exclude Files")
69 List of score files to exclude when the the current score file is loaded.
70 You can use this if you have a score file you want to share between a
71 number of newsgroups, except for the newsgroup this score file
72 matches. [ Did anyone get that? ]
74 Push the `[INS]' button add a score file to the list, or `[DEL]' to
75 delete a score file from the list.")
77 (data ((type . repeat
)
80 (directory . gnus-kill-files-directory
)))))
84 Articles below this score will be automatically marked as read.
86 This means that when you enter the summary buffer, the articles will
87 be shown but will already be marked as read. You can then press `x'
88 to get rid of them entirely.
90 By default articles with a negative score will be marked as read. To
91 change this, push the `Mark' button, and choose `Integer'. You can
92 then enter a value in the `Mark' field.")
93 (type . gnus-score-custom-maybe-type
))
97 Articles below this score will not be shown in the summary buffer.")
98 (type . gnus-score-custom-maybe-type
))
99 ((name . mark-and-expunge
)
100 (tag .
"Mark and Expunge")
102 Articles below this score will be marked as read, but not shown.
104 Someone should explain me the difference between this and `expunge'
105 alone or combined with `mark'.")
106 (type . gnus-score-custom-maybe-type
))
110 Evaluate this lisp expression when the entering summary buffer.")
114 (doc .
"Read-only score files will not be updated or saved.
115 Except from this buffer, of course!")
119 Each news header has an associated list of score entries.
120 You can use the [INS] buttons to add new score entries anywhere in the
121 list, or the [DEL] buttons to delete specific score entries.
123 Each score entry should specify a string that should be matched with
124 the content actual header in order to determine whether the entry
125 applies to that header. Enter that string in the `Match' field.
127 If the score entry matches, the articles score will be adjusted with
128 some amount. Enter that amount in the in the `Score' field. You
129 should specify a positive amount for score entries that matches
130 articles you find interesting, and a negative amount for score entries
131 matching articles you would rather avoid. The final score for the
132 article will be the sum of the score of all score entries that match
135 The score entry can be either permanent or expirable. To make the
136 entry permanent, push the `Date' button and choose the `Permanent'
137 entry. To make the entry expirable, choose instead the `Integer'
138 entry. After choosing the you can enter the date the score entry was
139 last matched in the `Date' field. The date will be automatically
140 updated each time the score entry matches an article. When the date
141 become too old, the the score entry will be removed.
143 For your convenience, the date is specified as the number of days
144 elapsed since the (imaginary) Gregorian date Sunday, December 31, 1
147 Finally, you can choose what kind of match you want to perform by
148 pushing the `Type' button. For most entries you can choose between
149 `Exact' which mean the header content must be exactly identical to the
150 match string, or `Substring' meaning the match string should be
151 somewhere in the header content, or even `Regexp' to use Emacs regular
152 expression matching. The last choice is `Fuzzy' which is like `Exact'
153 except that whitespace derivations, a beginning `Re:' or a terminating
154 parenthetical remark are all ignored. Each of the four types have a
155 variant which will ignore case in the comparison. That variant is
156 indicated with a `(fold)' after its name."))
159 (doc .
"Scoring based on the authors email address.")
160 (type . gnus-score-custom-string-type
))
163 (doc .
"Scoring based on the articles subject.")
164 (type . gnus-score-custom-string-type
))
167 (doc .
"Scoring based on who the article is a followup to.
169 If you want to see all followups to your own articles, add an entry
170 with a positive score matching your email address here. You can also
171 put an entry with a negative score matching someone who is so annoying
172 that you don't even want to see him quoted in followups.")
173 (type . gnus-score-custom-string-type
))
176 (doc .
"Scoring based on article crossposting.
178 If you want to score based on which newsgroups an article is posted
179 to, this is the header to use. The syntax is a little different from
180 the `Newsgroups' header, but scoring in `Xref' is much faster. As an
181 example, to match all crossposted articles match on `:.*:' using the
183 (type . gnus-score-custom-string-type
))
186 (doc .
"Scoring based on article references.
188 The `References' header gives you an alternative way to score on
189 followups. If you for example want to see follow all discussions
190 where people from `iesd.auc.dk' school participate, you can add a
191 substring match on `iesd.auc.dk>' on this header.")
192 (type . gnus-score-custom-string-type
))
195 (doc .
"Scoring based on the articles message-id.
197 This isn't very useful, but Lars like completeness. You can use it to
198 match all messaged generated by recent Gnus version with a `Substring'
200 (type . gnus-score-custom-string-type
))
203 WARNING: Scoring on the following three pseudo headers is very slow!
204 Scoring on any of the real headers use a technique that avoids
205 scanning the entire article, only the actual headers you score on are
206 scanned, and this scanning has been heavily optimized. Using just a
207 single entry for one the three pseudo-headers `Head', `Body', and
208 `All' will require GNUS to retrieve and scan the entire article, which
209 can be very slow on large groups. However, if you add one entry for
210 any of these headers, you can just as well add several. Each
211 subsequent entry cost relatively little extra time."))
214 (doc .
"Scoring based on the article header.
216 Instead of matching the content of a single header, the entire header
217 section of the article is matched. You can use this to match on
218 arbitrary headers, foe example to single out TIN lusers, use a substring
219 match on `Newsreader: TIN'. That should get 'em!")
220 (type . gnus-score-custom-string-type
))
223 (doc .
"Scoring based on the article body.
225 If you think any article that mentions `Kibo' is inherently
226 interesting, do a substring match on His name. You Are Allowed.")
227 (type . gnus-score-custom-string-type
))
230 (doc .
"Scoring based on the whole article.")
231 (type . gnus-score-custom-string-type
))
234 (doc .
"Scoring based on article date.
236 You can change the score of articles that have been posted before,
237 after, or at a specific date. You should add the date in the `Match'
238 field, and then select `before', `after', or `at' by pushing the
239 `Type' button. Imagine you want to lower the score of very old
240 articles, or want to raise the score of articles from the future (such
241 things happen!). Then you can't use date scoring for that. In fact,
242 I can't imagine anything you would want to use this for.
244 For your convenience, the date is specified in Usenet date format.")
245 (type . gnus-score-custom-date-type
))
248 The Lines and Chars headers use integer based scoring.
250 This means that you should write an integer in the `Match' field, and
251 the push the `Type' field to if the `Chars' or `Lines' header should
252 be larger, equal, or smaller than the number you wrote in the match
256 (doc .
"Scoring based on the number of characters in the article.")
257 (type . gnus-score-custom-integer-type
))
260 (doc .
"Scoring based on the number of lines in the article.")
261 (type . gnus-score-custom-integer-type
))
264 (doc .
"Score to add to articles with no parents.")
265 (type . gnus-score-custom-maybe-type
))
268 (doc .
"Adapting the score files to your newsreading habits.
270 When you have finished reading a group GNUS can automatically create
271 new score entries based on which articles you read and which you
272 skipped. This is normally controlled by the two global variables
273 `gnus-use-adaptive-scoring' and `gnus-default-adaptive-score-alist',
274 The first determines whether adaptive scoring should be enabled or
275 not, while the second determines what score entries should be created.
277 You can overwrite the setting of `gnus-use-adaptive-scoring' by
278 selecting `Enable' or `Disable' by pressing the `Adapt' button.
279 Selecting `Custom' will allow you to specify the exact adaptation
280 rules (overwriting `gnus-default-adaptive-score-alist').")
282 (data ((tag .
"Default")
292 (doc .
"Customization of adaptive scoring.
294 Each time you read an article it will be marked as read. Likewise, if
295 you delete it it will be marked as deleted, and if you tick it it will
296 be marked as ticked. When you leave a group, GNUS can automatically
297 create score file entries based on these marks, so next time you enter
298 the group articles with subjects that you read last time have higher
299 score and articles with subjects that deleted will have lower score.
301 Below is a list of such marks. You can insert new marks to the list
302 by pushing on one of the `[INS]' buttons in the left margin to create
303 a new entry and then pushing the `Mark' button to select the mark.
304 For each mark there is another list, this time of article headers,
305 which determine how the mark should affect that header. The `[INS]'
306 buttons of this list are indented to indicate that the belong to the
307 mark above. Push the `Header' button to choose a header, and then
308 enter a score value in the `Score' field.
310 For each article that are marked with `Mark' when you leave the
311 group, a temporary score entry for the articles `Header' with the
312 value of `Score' will be added the adapt file. If the score entry
313 already exists, `Score' will be added to its value. If you understood
316 You can select the special value `Other' when pressing the `Mark' or
317 `Header' buttons. This is because Lars might add more useful values
318 there. If he does, it is up to you to figure out what they are named.")
320 (default .
((__uninitialized__)))
321 (data ((type . repeat
)
323 (data .
((type . list
)
326 (data ((type . choice
)
328 (data ((tag .
"Unread")
329 (default . gnus-unread-mark
)
332 (default . gnus-ticked-mark
)
335 (default . gnus-dormant-mark
)
338 (default . gnus-del-mark
)
341 (default . gnus-read-mark
)
344 (default . gnus-expirable-mark
)
347 (default . gnus-killed-mark
)
350 (default . gnus-kill-file-mark
)
353 (default . gnus-low-score-mark
)
356 (default . gnus-catchup-mark
)
359 (default . gnus-ancient-mark
)
362 (default . gnus-canceled-mark
)
369 (data .
((type . list
)
371 (data ((tag .
"Header")
373 (data ((tag .
"Subject")
385 (type . integer
))))))))))))))
389 List of local variables to set when this score file is loaded.
391 Using this entry can provide a convenient way to set variables that
392 will affect the summary mode for only some specific groups, i.e. those
393 groups matched by the current score file.")
395 (data ((type . repeat
)
397 (data .
((type . list
)
399 (data ((tag .
"Name")
404 (type . sexp
)))))))))))
406 (defconst gnus-score-custom-type-properties
407 '((gnus-score-custom-maybe-type
409 (data ((type . integer
)
414 (gnus-score-custom-string-type
416 (data ((type . repeat
)
418 (data .
((type . list
)
420 (data ((tag .
"Match")
428 (data ((type . integer
)
436 (data ((tag .
"Exact")
448 ((tag .
"Exact (fold)")
451 ((tag .
"Substring (fold)")
454 ((tag .
"Regexp (fold)")
457 ((tag .
"Fuzzy (fold)")
459 (type . const
))))))))))
460 (gnus-score-custom-integer-type
462 (data ((type . repeat
)
464 (data .
((type . list
)
466 (data ((tag .
"Match")
472 (data ((type . integer
)
494 (type . const
))))))))))
495 (gnus-score-custom-date-type
497 (data ((type . repeat
)
499 (data .
((type . list
)
501 (data ((tag .
"Match")
509 (data ((type . integer
)
517 (data ((tag .
"Before")
525 (type . const
))))))))))))
527 (defvar gnus-score-custom-file nil
528 "Name of SCORE file being customized.")
530 (defun gnus-score-customize ()
531 "Create a buffer for editing gnus SCORE files."
533 (let (gnus-score-alist)
534 (custom-buffer-create "*Score Edit*" gnus-score-custom-data
535 gnus-score-custom-type-properties
536 'gnus-score-custom-set
537 'gnus-score-custom-get
538 'gnus-score-custom-save
))
539 (make-local-variable 'gnus-score-custom-file
)
540 (setq gnus-score-custom-file
541 (expand-file-name "SCORE" gnus-kill-files-directory
))
542 (make-local-variable 'gnus-score-alist
)
543 (setq gnus-score-alist nil
)
546 (defun gnus-score-custom-get (name)
548 gnus-score-custom-file
549 (let ((entry (assoc (symbol-name name
) gnus-score-alist
)))
551 (mapcar 'gnus-score-custom-sanify
(cdr entry
))
552 (setq entry
(assoc name gnus-score-alist
))
553 (if (or (memq name
'(files exclude-files local
))
554 (and (eq name
'adapt
)
555 (not (symbolp (car (cdr entry
))))))
557 (car (cdr entry
)))))))
559 (defun gnus-score-custom-set (name value
)
560 (cond ((eq name
'file
)
561 (setq gnus-score-custom-file value
))
562 ((assoc (symbol-name name
) gnus-score-alist
)
564 (setcdr (assoc (symbol-name name
) gnus-score-alist
) value
)
565 (setq gnus-score-alist
(delq (assoc (symbol-name name
)
568 ((assoc (symbol-name name
) gnus-header-index
)
570 (setq gnus-score-alist
571 (cons (cons (symbol-name name
) value
) gnus-score-alist
))))
572 ((assoc name gnus-score-alist
)
574 (setq gnus-score-alist
(delq (assoc name gnus-score-alist
)
576 ((and (listp value
) (not (eq name
'eval
)))
577 (setcdr (assoc name gnus-score-alist
) value
))
579 (setcdr (assoc name gnus-score-alist
) (list value
)))))
581 ((and (listp value
) (not (eq name
'eval
)))
582 (setq gnus-score-alist
(cons (cons name value
) gnus-score-alist
)))
584 (setq gnus-score-alist
585 (cons (cons name
(list value
)) gnus-score-alist
)))))
587 (defun gnus-score-custom-sanify (entry)
589 (or (nth 1 entry
) gnus-score-interactive-default-score
)
591 (cond ((null (nth 3 entry
))
593 ((memq (nth 3 entry
) '(before after at
>= <=))
596 (intern (substring (symbol-name (nth 3 entry
)) 0 1))))))
598 (defvar gnus-score-cache nil
)
600 (defun gnus-score-custom-load ()
602 (let ((file (custom-name-value 'file
)))
603 (if (eq file custom-nil
)
604 (error "You must specify a file name"))
605 (setq file
(expand-file-name file gnus-kill-files-directory
))
606 (gnus-score-load file
)
607 (setq gnus-score-custom-file file
)
609 (gnus-message 4 "Loaded")))
611 (defun gnus-score-custom-save ()
614 (gnus-score-remove-from-cache gnus-score-custom-file
)
615 (let ((file gnus-score-custom-file
)
616 (score gnus-score-alist
)
617 emacs-lisp-mode-hook
)
619 (set-buffer (get-buffer-create "*Score*"))
620 (buffer-disable-undo (current-buffer))
622 (pp score
(current-buffer))
623 (gnus-make-directory (file-name-directory file
))
624 (write-region (point-min) (point-max) file nil
'silent
)
625 (kill-buffer (current-buffer))))
626 (gnus-message 4 "Saved"))
630 ;;; gnus-edit.el end here