bbc@legia.rice.edu (Benjamin Chase) (02/25/90)
[Quicky definition of gnus-kill supplied for the reader's convenience.] (defun gnus-kill (field regexp &optional command all) "If FIELD of an article matches REGEXP, execute COMMAND. Currently, gnus-kill is set up to munch on articles whose FIELD matches a particular REGEXP. This is accomplished (two levels down) by calling string-match on the regular expression REGEXP and the value of the indicated field FIELD. I'd like to change gnus-kill, or something similar, so that you can supply a function of one argument in the place of REGEXP, the regular expression that is matched against the specified field. Why? So I can do something like: ; Return true if the value of an Xref field mentions more ; than two newsgroups. (defun xref-killer (xref-line) (and xref-line (> (length (gnus-parse-xref-field xref-line)) 2))) ; Kill excessively crossposted articles. (gnus-kill "Xref" 'xref-killer) Without this, the only way to chew on the Xref field in a general way is to write fairly disgusting regular expressions. I found this annoying, especially when I found gnus-parse-xref-field, which was begging to be used to preprocess the Xref field. The function supplied to gnus-kill would take the value of FIELD as an argument and return t or nil. Thus, the case where REGEXP was still really a regular expression would be equivalent to calling (something like): (gnus-kill FIELD (function (lambda (field-value) (string-match REGEXP field-value))) ... ) (Excuse any silly mistakes, I just typed it in without thinking too deeply.) Of course, that equivalence would be pushed down into gnus-kill, so that the lambda would be hidden within it. Or perhaps it would be pushed further down, into gnus-execute? Of course, you'd want to find a better name for REGEXP, since it's not just a regular expression any more. Comments? -- Ben Chase <bbc@rice.edu>, Rice University, Houston, Texas
allbery@NCoast.ORG (Brandon S. Allbery) (02/26/90)
As quoted from <BBC.90Feb24185812@legia.rice.edu> by bbc@legia.rice.edu (Benjamin Chase): +--------------- | (defun gnus-kill (field regexp &optional command all) | "If FIELD of an article matches REGEXP, execute COMMAND. | | I'd like to change gnus-kill, or something similar, so that you can | supply a function of one argument in the place of REGEXP, the regular | expression that is matched against the specified field. Why? So I | can do something like: | | ; Return true if the value of an Xref field mentions more | ; than two newsgroups. +--------------- (gnus-kill "Xref" ".*" 'kill-article-if-too-many-xrefs) You *can* do all the selection in the executive function, you know. Just select every value of the "Xref" field, then let your command issue the actual kill command if it sees something it doesn't like. ++Brandon -- Brandon S. Allbery (human), allbery@NCoast.ORG (Inet), BALLBERY (MCI Mail) ALLBERY (Delphi), uunet!cwjcc.cwru.edu!ncoast!allbery (UUCP), B.ALLBERY (GEnie) BrandonA (A-Online) ("...and a partridge in a pear tree!" ;-)