unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* gnus mail-splitting tweak
@ 2003-05-14  8:35 Miles Bader
  2003-05-14  9:25 ` Simon Josefsson
  0 siblings, 1 reply; 2+ messages in thread
From: Miles Bader @ 2003-05-14  8:35 UTC (permalink / 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: gnus mail-splitting tweak
  2003-05-14  8:35 gnus mail-splitting tweak Miles Bader
@ 2003-05-14  9:25 ` Simon Josefsson
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Josefsson @ 2003-05-14  9:25 UTC (permalink / raw)
  Cc: emacs-devel

Miles Bader <miles@lsi.nec.co.jp> writes:

> 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:

This should be implemented in 5.10, the variable is called
nnmail-article-buffer.

> BTW, is there a gnus-specific mailing-list this sort of thing should be
> sent to?

ding@gnus.org.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-05-14  9:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-14  8:35 gnus mail-splitting tweak Miles Bader
2003-05-14  9:25 ` Simon Josefsson

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).