From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Miles Bader Newsgroups: gmane.emacs.devel Subject: gnus mail-splitting tweak Date: 14 May 2003 17:35:18 +0900 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: Reply-To: Miles Bader NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1052901811 14989 80.91.224.249 (14 May 2003 08:43:31 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 14 May 2003 08:43:31 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Wed May 14 10:43:27 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19FrrD-0003tD-00 for ; Wed, 14 May 2003 10:43:27 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 19FryV-0007Wc-00 for ; Wed, 14 May 2003 10:51:00 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19FrsK-0004MG-03 for emacs-devel@quimby.gnus.org; Wed, 14 May 2003 04:44:36 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 19Frrx-0004Li-00 for emacs-devel@gnu.org; Wed, 14 May 2003 04:44:13 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 19Frrw-0004LX-00 for emacs-devel@gnu.org; Wed, 14 May 2003 04:44:13 -0400 Original-Received: from tyo201.gate.nec.co.jp ([202.32.8.214]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19Frlb-0001Bk-00; Wed, 14 May 2003 04:37:39 -0400 Original-Received: from mailgate3.nec.co.jp ([10.7.69.192])h4E8baA29813; Wed, 14 May 2003 17:37:36 +0900 (JST) Original-Received: (from root@localhost) by mailgate3.nec.co.jp (8.11.6/3.7W-MAILGATE-NEC) id h4E8bZG01826; Wed, 14 May 2003 17:37:35 +0900 (JST) Original-Received: from edtmg02.lsi.nec.co.jp ([10.26.16.202]) by mailsv2.nec.co.jp (8.11.6p2/3.7W-MAILSV2-NEC) with ESMTP id h4E8ZKP03978; Wed, 14 May 2003 17:37:18 +0900 (JST) Original-Received: from mcsss2.ucom.lsi.nec.co.jp (localhost [127.0.0.1]) id RAA03186; Wed, 14 May 2003 17:35:19 +0900 (JST) Original-Received: from mcspd15.ucom.lsi.nec.co.jp (mcspd15 [10.30.114.174]) with ESMTP id h4E8ZJNH004192; Wed, 14 May 2003 17:35:19 +0900 (JST) Original-Received: by mcspd15.ucom.lsi.nec.co.jp (Postfix, from userid 31295) id 1B13E3700; Wed, 14 May 2003 17:35:18 +0900 (JST) Original-To: emacs-devel@gnu.org System-Type: i686-pc-linux-gnu Blat: Foop Original-Lines: 70 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:13848 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:13848 In Gnus, the `nnmail-split-fancy' variable can contain functions, which are called to provide more arbitrary matching capabilities. They are evaluated in a buffer containing only the article headers. If you want to do splitting on the message contents as well, the documentation contains the following suggestion: (defun split-on-body () (save-excursion (set-buffer " *nnmail incoming*") (goto-char (point-min)) (when (re-search-forward "Some.*string" nil t) "string.group"))) However, using " *nnmail incoming*" has several disadvantages -- (1) it's a funny looking magic string, which feels like it could change in the future, and (2) it's not always the right buffer, e.g., when you respool articles. What do you think of the following change, which explicitly exports a variable dynamically bound to the appropriate buffer: --- nnmail.el.~1.19.~ 2003-02-05 10:06:32.000000000 +0900 +++ nnmail.el 2003-05-14 17:25:30.000000000 +0900 @@ -1,5 +1,5 @@ ;;; nnmail.el --- mail support functions for the Gnus mail backends -;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2002 +;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003 ;; Free Software Foundation, Inc. ;; Author: Lars Magne Ingebrigtsen @@ -920,11 +920,14 @@ FUNC will be called with the buffer narr (funcall exit-func)) (kill-buffer (current-buffer)))))) +(defvar nnmail-split-article-buffer nil + "During splitting, bound to a buffer containing the original article.") + (defun nnmail-article-group (func &optional trace) "Look at the headers and return an alist of groups that match. FUNC will be called with the group name to determine the article number." (let ((methods nnmail-split-methods) - (obuf (current-buffer)) + (nnmail-split-article-buffer (current-buffer)) (beg (point-min)) end group-art method grp) (if (and (sequencep methods) @@ -941,7 +944,7 @@ FUNC will be called with the group name (set-buffer nntp-server-buffer) (erase-buffer) ;; Copy the headers into the work buffer. - (insert-buffer-substring obuf beg end) + (insert-buffer-substring nnmail-split-article-buffer beg end) ;; Fold continuation lines. (goto-char (point-min)) (while (re-search-forward "\\(\r?\n[ \t]+\\)+" nil t) [not tested, but pretty straight-forward.] BTW, is there a gnus-specific mailing-list this sort of thing should be sent to? Thanks, -Miles -- Somebody has to do something, and it's just incredibly pathetic that it has to be us. -- Jerry Garcia