Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!uwm.edu!cs.utexas.edu!rice!brazos.rice.edu!bbc From: bbc@legia.rice.edu (Benjamin Chase) Newsgroups: gnu.emacs.gnus Subject: changing meaning of gnus-execute, ... Message-ID: Date: 25 Feb 90 00:58:12 GMT Sender: root@rice.edu Reply-To: Benjamin Chase Distribution: gnu Organization: Center for Research on Parallel Computations Lines: 53 [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 , Rice University, Houston, Texas