From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/54703 Path: main.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.gnus.general Subject: Re: displaying arbitrary headers in summary Date: Thu, 06 Nov 2003 14:58:14 -0500 Organization: =?koi8-r?q?=F4=C5=CF=C4=CF=D2=20=FA=CC=C1=D4=C1=CE=CF=D7?= @ Cienfuegos Sender: ding-owner@lists.math.uh.edu Message-ID: <4nsml12rs9.fsf@koz.bwh.harvard.edu> References: <87znf9d6i8.fsf@w3.org> <87islx1hsg.fsf@mulligatwani.msrl.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1068148823 19206 80.91.224.253 (6 Nov 2003 20:00:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 6 Nov 2003 20:00:23 +0000 (UTC) Cc: Max Froumentin , ding@gnus.org Original-X-From: ding-owner+M3244@lists.math.uh.edu Thu Nov 06 21:00:20 2003 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AHqIl-0005pU-00 for ; Thu, 06 Nov 2003 21:00:19 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1AHqIT-0004Gy-00; Thu, 06 Nov 2003 14:00:01 -0600 Original-Received: from justine.libertine.org ([66.139.78.221]) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1AHqIK-0004Gs-00 for ding@lists.math.uh.edu; Thu, 06 Nov 2003 13:59:53 -0600 Original-Received: from clifford.bwh.harvard.edu (clifford.bwh.harvard.edu [134.174.9.41]) by justine.libertine.org (Postfix) with ESMTP id F40A13A005E for ; Thu, 6 Nov 2003 13:59:51 -0600 (CST) Original-Received: from koz.bwh.harvard.edu (koz [134.174.9.110]) by clifford.bwh.harvard.edu (8.10.2+Sun/8.11.0) with ESMTP id hA6Jx5723890; Thu, 6 Nov 2003 14:59:05 -0500 (EST) Original-Received: (from tzz@localhost) by koz.bwh.harvard.edu (8.11.6+Sun/8.11.0) id hA6JwEs17015; Thu, 6 Nov 2003 14:58:14 -0500 (EST) Original-To: Michael Shields X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6;d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" Mail-Followup-To: Michael Shields , Max Froumentin , ding@gnus.org In-Reply-To: <87islx1hsg.fsf@mulligatwani.msrl.com> (Michael Shields's message of "Thu, 06 Nov 2003 18:19:27 +0000") User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (usg-unix-v) Precedence: bulk Xref: main.gmane.org gmane.emacs.gnus.general:54703 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:54703 On Thu, 06 Nov 2003, shields@msrl.com wrote: > In message <87znf9d6i8.fsf@w3.org>, > Max Froumentin wrote: >> Basically, I'd like to display the spamassassin score of each >> article in each line of the summary buffer. It's probably not easy >> since the content of the X-Spam-Status is not in the .now file by >> default, but maybe there's a way to put it in there. > > Here is one approach, along with a function that sorts by spam > score: > > (add-to-list 'nnmail-extra-headers 'X-Spam-Status) > (defun gnus-article-spamassassin-score (header) > "Return the Spamassassin score of this article, as a string." > (gnus-replace-in-string > (gnus-replace-in-string > (gnus-extra-header 'X-Spam-Status header) > ".*hits=" "") > " .*" "")) > (defun gnus-user-format-function-s (header) > (gnus-article-spamassassin-score header)) > (defun gnus-article-sort-by-spam-status (h1 h2) > "Sort articles by Spamassassin score." > (< (string-to-number (gnus-article-spamassassin-score h1)) > (string-to-number (gnus-article-spamassassin-score h2)))) Can this go into spam.el, to be turned on by default for Bogofilter and spam-use-regex (SpamAssassin) users if the users request it? It seems reasonable that the X-Spam-Status and similar headers should be handled for summary formats, etc. by spam.el. Maybe it can interface with the existing scoring functions for Bogofilter. I've been thinking about uniform weighted scoring for spam.el - something that will always score between -1 and 1. For instance, SA scores, which can be between -inf. and inf. could be weighted like so: ;;; assuming a range from -1 to 1 (defun normalize (score &optional offset) (let* ((score (float score)) (offset (if offset (float offset) 0)) (offset-score (- score offset))) (if (zerop offset-score) 0 (let* ((absolute-weighted-score (/ 2 offset-score)) (adjustment (if (> offset-score 0) 1 -1))) (- adjustment absolute-weighted-score))))) What do you think?. > Now you can use "%us" in your gnus-summary-line-format to display > the spam score. You could add to your spamtrap folder's group > parameters: > > (gnus-summary-line-format "%U%R%z%I%(%[%6us: %-23,23f%]%) %s\n") > (gnus-article-sort-functions > '(gnus-article-sort-by-spam-status)) > > This displays the score for each article, and also puts the most > likely false positives at the top. Looks very useful! I don't think any of this belongs in spam.el of course, but it should probably go in the manual if we add your formatting and headers code above. Ted