[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnus mail-splitting tweak

From: Miles Bader
Subject: gnus mail-splitting tweak
Date: 14 May 2003 17:35:18 +0900

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 ()
       (set-buffer " *nnmail incoming*")
       (goto-char (point-min))
       (when (re-search-forward "Some.*string" nil t)

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 <address@hidden>
@@ -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)
        ;; 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?


Somebody has to do something, and it's just incredibly pathetic that it
has to be us.  -- Jerry Garcia

reply via email to

[Prev in Thread] Current Thread [Next in Thread]