unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Miles Bader <miles@lsi.nec.co.jp>
Subject: gnus mail-splitting tweak
Date: 14 May 2003 17:35:18 +0900	[thread overview]
Message-ID: <buo4r3yudrt.fsf@mcspd15.ucom.lsi.nec.co.jp> (raw)

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 <larsi@gnus.org>
@@ -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

             reply	other threads:[~2003-05-14  8:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-14  8:35 Miles Bader [this message]
2003-05-14  9:25 ` gnus mail-splitting tweak Simon Josefsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=buo4r3yudrt.fsf@mcspd15.ucom.lsi.nec.co.jp \
    --to=miles@lsi.nec.co.jp \
    --cc=miles@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).