From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/21599 Path: main.gmane.org!not-for-mail From: Kai.Grossjohann@CS.Uni-Dortmund.DE Newsgroups: gmane.emacs.gnus.general Subject: split followups to go with parent Date: 26 Feb 1999 18:46:33 +0100 Sender: owner-ding@hpc.uh.edu Message-ID: NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1035159672 23776 80.91.224.250 (21 Oct 2002 00:21:12 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 00:21:12 +0000 (UTC) Return-Path: Original-Received: from fisher.math.uh.edu (fisher.math.uh.edu [129.7.128.35]) by sclp3.sclp.com (8.8.5/8.8.5) with ESMTP id MAA12261 for ; Fri, 26 Feb 1999 12:49:09 -0500 (EST) Original-Received: from sina.hpc.uh.edu (lists@Sina.HPC.UH.EDU [129.7.3.5]) by fisher.math.uh.edu (8.9.1/8.9.1) with ESMTP id LAB12996; Fri, 26 Feb 1999 11:48:03 -0600 (CST) Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Fri, 26 Feb 1999 11:48:55 -0600 (CST) Original-Received: from sclp3.sclp.com (root@sclp3.sclp.com [204.252.123.139]) by sina.hpc.uh.edu (8.7.3/8.7.3) with ESMTP id LAA10537 for ; Fri, 26 Feb 1999 11:48:45 -0600 (CST) Original-Received: from waldorf.cs.uni-dortmund.de (waldorf.cs.uni-dortmund.de [129.217.4.42]) by sclp3.sclp.com (8.8.5/8.8.5) with ESMTP id MAA12215 for ; Fri, 26 Feb 1999 12:47:04 -0500 (EST) Original-Received: from ramses.informatik.uni-dortmund.de (ramses.cs.uni-dortmund.de [129.217.20.180]) by waldorf.cs.uni-dortmund.de with SMTP id SAA08331 for ; Fri, 26 Feb 1999 18:46:35 +0100 (MET) Original-Received: (grossjoh@localhost) by ramses.informatik.uni-dortmund.de id SAA21281; Fri, 26 Feb 1999 18:46:34 +0100 Original-To: ding@gnus.org Original-Lines: 151 User-Agent: Gnus/5.070077 (Pterodactyl Gnus v0.77) Emacs/20.3 Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:21599 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:21599 This is a MIME multipart message. If you are reading this, you shouldn't. --=-=-= This is a patch for nnmail.el. As you can see, it's been created for the mid sixties, but it still works. What does it do? It stores additional information in ~/.nnmail-cache; in addition to the message id the group name is stored as well (for mail groups only). It also defines a function to be used in nnmail-split-fancy which looks at the References header of each incoming message and searches the message ids in ~/.nnmail-cache. When a message id is found, the group name next to that message id is used as the group to split to. This is a complicated explanation. Let me try to illustrate this with an example. Let's say you receive a message M which is split to nnml:mail.misc by your fancy splitting rules. Let's say you then *manually* move this message to some other group, nnml:mail.foo. Suppose someone sends you a followup F to the message M. Surely you would like F to be split to nnml:mail.foo, as well. But the fancy split methods don't know about the manual movement, and thus they would choose nnml:mail.misc. Well, with this patch the followup is also split to nnml:mail.foo. ,----- | (setq | nnmail-split-fancy | '(| (: nnmail-split-fancy-with-parent) | ("x-mailing-list" "bbdb-info@xemacs.org" "auto.bbdb") `----- This is the beginning of my nnmail-split-fancy value, as an illustration how to use the whole thing. I would like you to test this patch if it also works for you. Beware of nnmail-split-fancy putting stuff in the bogus group if there is an error. Other than that, this should be benign. I've got an agreement with Lars. He wants to rewrite the mail fetching stuff (he's already started to do so with mail-source.el), and then the patch will break. But if we discover that the users (i.e. you) think that this behavior is a nice thing to have, maybe Lars will build it right into the new mail fetching stuff. (In case you're wondering: currently, the first backend which can receive mail gets all of it. Lars wants to allow one to specify which backend a mail should go to.) Let me know what you think, kai -- I like _b_o_t_h kinds of music. --=-=-= Content-Type: application/x-patch; name=nnmail.el-patch-pgnus-0.63 Content-Disposition: attachment; filename=nnmail.el-patch-pgnus-0.63 Content-Transfer-Encoding: 8bit --- lisp/nnmail.el.orig Mon Nov 30 22:47:02 1998 +++ lisp/nnmail.el Fri Dec 4 13:34:02 1998 @@ -1489,12 +1489,78 @@ (defun nnmail-cache-insert (id) (when nnmail-treat-duplicates - (unless (gnus-buffer-live-p nnmail-cache-buffer) - (nnmail-cache-open)) + ;; Store some information about the group this message is written + ;; to. This function might have been called from various places. + ;; Sometimes, a function up in the calling sequence has an + ;; argument GROUP which is bound to a string, the group name. At + ;; other times, there is a function up in the calling sequence + ;; which has an argument GROUP-ART which is a list of pairs, and + ;; the car of a pair is a group name. Should we check that the + ;; length of the list is equal to 1? -- kai + (let ((g nil)) + (cond ((and (boundp 'group) group) + (setq g group)) + ((and (boundp 'group-art-list) group-art-list + (listp group-art-list)) + (setq g (caar group-art-list))) + ((and (boundp 'group-art) group-art (listp group-art)) + (setq g (caar group-art))) + (t (setq g ""))) + (unless (gnus-buffer-live-p nnmail-cache-buffer) + (nnmail-cache-open)) + (save-excursion + (set-buffer nnmail-cache-buffer) + (goto-char (point-max)) + (if (and g (not (string= "" g)) + (gnus-methods-equal-p gnus-command-method + (nnmail-cache-primary-mail-backend))) + (insert id "\t" g "\n") + (insert id "\n")))))) + +(defun nnmail-cache-primary-mail-backend () + (let ((be-list (cons gnus-select-method gnus-secondary-select-methods)) + (be nil) + (res nil)) + (while (and (null res) be-list) + (setq be (car be-list)) + (setq be-list (cdr be-list)) + (when (and (gnus-method-option-p be 'respool) + (eval (intern (format "%s-get-new-mail" (car be))))) + (setq res be))) + res)) + +;; Fetch the group name corresponding to the message id stored in the +;; cache. +(defun nnmail-cache-fetch-group (id) + (when (and nnmail-treat-duplicates nnmail-cache-buffer) (save-excursion (set-buffer nnmail-cache-buffer) (goto-char (point-max)) - (insert id "\n")))) + (when (search-backward id nil t) + (beginning-of-line) + (skip-chars-forward "^\n\r\t") + (unless (eolp) + (forward-char 1) + (buffer-substring (point) + (progn (end-of-line) (point)))))))) + +;; Function for nnmail-split-fancy: look up all references in the +;; cache and if a match is found, return that group. +(defun nnmail-split-fancy-with-parent () + (let* ((refstr (or (message-fetch-field "references") + (message-fetch-field "in-reply-to"))) + (references nil) + (res nil)) + (when refstr + (setq references (nreverse (gnus-split-references refstr))) + (unless (gnus-buffer-live-p nnmail-cache-buffer) + (nnmail-cache-open)) + (mapcar (lambda (x) + (setq res (or (nnmail-cache-fetch-group x) res)) + (when (string= "drafts" res) + (setq res nil))) + references) + res))) (defun nnmail-cache-id-exists-p (id) (when nnmail-treat-duplicates --=-=-=--