Gnus development mailing list
 help / color / mirror / Atom feed
* Group splitting on list headers
@ 2013-12-14 17:03 Daniel Dehennin
  2013-12-26 15:47 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Dehennin @ 2013-12-14 17:03 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 2284 bytes --]

Hello,

I'm heavily using Group splitting and I have an issue with mailing-list
and cross-posting.

I'm looking at splitting on mailing-list headers and wonder if this is
the correct way of doing it.

I first create a new “list” abbrev:

#+begin_src diff
diff --git a/lisp/nnmail.el b/lisp/nnmail.el
index 5be449e..73023df 100644
--- a/lisp/nnmail.el
+++ b/lisp/nnmail.el
@@ -517,6 +517,7 @@ Example:
 (defcustom nnmail-split-abbrev-alist
   '((any . "from\\|to\\|cc\\|sender\\|apparently-to\\|resent-from\\|resent-to\\|resent-cc")
     (mail . "mailer-daemon\\|postmaster\\|uucp")
+    (list . "List-Post\\|X-BeenThere\\|X-Loop\||X-.*List")
     (to . "to\\|cc\\|apparently-to\\|resent-to\\|resent-cc")
     (from . "from\\|sender\\|resent-from")
     (nato . "to\\|cc\\|resent-to\\|resent-cc")
#+end_src

And then I use the “subscribed” group parameter to discriminate the use
of “list” in place of “any”

#+begin_src diff
diff --git a/lisp/gnus-mlspl.el b/lisp/gnus-mlspl.el
index 3947c67..303aec5 100644
--- a/lisp/gnus-mlspl.el
+++ b/lisp/gnus-mlspl.el
@@ -177,7 +177,10 @@ Calling (gnus-group-split-fancy nil nil \"mail.others\") returns:
 		    (to-list (cdr (assoc 'to-list params)))
 		    (extra-aliases (cdr (assoc 'extra-aliases params)))
 		    (split-regexp (cdr (assoc 'split-regexp params)))
-		    (split-exclude (cdr (assoc 'split-exclude params))))
+		    (split-exclude (cdr (assoc 'split-exclude params)))
+		    (target (if (cdr (assoc 'subscribed params))
+				'list
+			      'any)))
 		(when (or to-address to-list extra-aliases split-regexp)
 		  ;; regexp-quote to-address, to-list and extra-aliases
 		  ;; and add them all to split-regexp
@@ -198,7 +201,7 @@ Calling (gnus-group-split-fancy nil nil \"mail.others\") returns:
 			 "\\)"))
 		  ;; Now create the new SPLIT
 		  (push (append
-			 (list 'any split-regexp)
+			 (list target split-regexp)
 			 ;; Generate RESTRICTs for SPLIT-EXCLUDEs.
 			 (if (listp split-exclude)
 			     (apply #'append
#+end_src

I wonder if using the “subscribed” is a good thing or maybe should I
define a new group parameter?

Regards.
-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x7A6FE2DF

[-- Attachment #2: Type: application/pgp-signature, Size: 229 bytes --]

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

* Re: Group splitting on list headers
  2013-12-14 17:03 Group splitting on list headers Daniel Dehennin
@ 2013-12-26 15:47 ` Lars Ingebrigtsen
  2013-12-26 16:58   ` Daniel Dehennin
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2013-12-26 15:47 UTC (permalink / raw)
  To: ding

Daniel Dehennin <daniel.dehennin@baby-gnu.org> writes:

> I wonder if using the “subscribed” is a good thing or maybe should I
> define a new group parameter?

Hm...  perhaps it would be best to define a new parameter, since this is
a new thing?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/



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

* Re: Group splitting on list headers
  2013-12-26 15:47 ` Lars Ingebrigtsen
@ 2013-12-26 16:58   ` Daniel Dehennin
  2013-12-26 16:59     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Dehennin @ 2013-12-26 16:58 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 380 bytes --]

Lars Ingebrigtsen <larsi@gnus.org> writes:


Hello,

> Hm...  perhaps it would be best to define a new parameter, since this is
> a new thing?

Ok, do you have any convention?

- match-list
- match-list-headers
- match-on-list-headers
- use-list-headers

Regards.
-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x7A6FE2DF

[-- Attachment #2: Type: application/pgp-signature, Size: 229 bytes --]

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

* Re: Group splitting on list headers
  2013-12-26 16:58   ` Daniel Dehennin
@ 2013-12-26 16:59     ` Lars Ingebrigtsen
  2013-12-27 15:57       ` [PATCH] " Daniel Dehennin
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2013-12-26 16:59 UTC (permalink / raw)
  To: ding

Daniel Dehennin <daniel.dehennin@baby-gnu.org> writes:

>> Hm...  perhaps it would be best to define a new parameter, since this is
>> a new thing?
>
> Ok, do you have any convention?
>
> - match-list
> - match-list-headers
> - match-on-list-headers
> - use-list-headers

Uhm...  perhaps `match-list'?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/



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

* [PATCH] Re: Group splitting on list headers
  2013-12-26 16:59     ` Lars Ingebrigtsen
@ 2013-12-27 15:57       ` Daniel Dehennin
  2013-12-28  1:53         ` Daniel Dehennin
  2013-12-29  0:25         ` Daniel Dehennin
  0 siblings, 2 replies; 7+ messages in thread
From: Daniel Dehennin @ 2013-12-27 15:57 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 4299 bytes --]

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Uhm...  perhaps `match-list'?

Shortest is best ;-)

You can review my proposal patch on my gitweb[1] or with the following
pull request.

Tell me if something should be changed.

Regards.

The following changes since commit 934f25f8d8801afe315722fd0b0b4ea14bcb1534:

  Make split tracing work in nnimap groups, too (2013-12-26 17:39:39 +0100)

are available in the git repository at:

  git://git.baby-gnu.net/gnus.git tags/feature/group-mail-splitting-on-list-headers

for you to fetch changes up to 2ff14c69a7ad8c4256236331fbe94ff43dd9976a:

  Add Group Mail Spliting on mailing-list headers (2013-12-27 16:54:15 +0100)

----------------------------------------------------------------
We define a new `list' abbreviation and `match-list' group parameter
and make Group Mail Splitting generate a SPLIT using it.

----------------------------------------------------------------
Daniel Dehennin (1):
      Add Group Mail Spliting on mailing-list headers

 lisp/gnus-mlspl.el |  7 +++++--
 lisp/nnmail.el     |  1 +
 texi/gnus.texi     | 15 +++++++++++++++
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/lisp/gnus-mlspl.el b/lisp/gnus-mlspl.el
index 3947c67..1997f43 100644
--- a/lisp/gnus-mlspl.el
+++ b/lisp/gnus-mlspl.el
@@ -177,7 +177,10 @@ Calling (gnus-group-split-fancy nil nil \"mail.others\") returns:
 		    (to-list (cdr (assoc 'to-list params)))
 		    (extra-aliases (cdr (assoc 'extra-aliases params)))
 		    (split-regexp (cdr (assoc 'split-regexp params)))
-		    (split-exclude (cdr (assoc 'split-exclude params))))
+		    (split-exclude (cdr (assoc 'split-exclude params)))
+		    (match-abbrev (if (cdr (assoc 'match-list params))
+				      'list
+				    'any)))
 		(when (or to-address to-list extra-aliases split-regexp)
 		  ;; regexp-quote to-address, to-list and extra-aliases
 		  ;; and add them all to split-regexp
@@ -198,7 +201,7 @@ Calling (gnus-group-split-fancy nil nil \"mail.others\") returns:
 			 "\\)"))
 		  ;; Now create the new SPLIT
 		  (push (append
-			 (list 'any split-regexp)
+			 (list match-abbrev split-regexp)
 			 ;; Generate RESTRICTs for SPLIT-EXCLUDEs.
 			 (if (listp split-exclude)
 			     (apply #'append
diff --git a/lisp/nnmail.el b/lisp/nnmail.el
index 5be449e..03d610c 100644
--- a/lisp/nnmail.el
+++ b/lisp/nnmail.el
@@ -517,6 +517,7 @@ Example:
 (defcustom nnmail-split-abbrev-alist
   '((any . "from\\|to\\|cc\\|sender\\|apparently-to\\|resent-from\\|resent-to\\|resent-cc")
     (mail . "mailer-daemon\\|postmaster\\|uucp")
+    (list . "list-post\\|x-beenthere\\|x-loop")
     (to . "to\\|cc\\|apparently-to\\|resent-to\\|resent-cc")
     (from . "from\\|sender\\|resent-from")
     (nato . "to\\|cc\\|resent-to\\|resent-cc")
diff --git a/texi/gnus.texi b/texi/gnus.texi
index 498c8a4..03af068 100644
--- a/texi/gnus.texi
+++ b/texi/gnus.texi
@@ -3103,6 +3103,18 @@ interest in relation to the sieve parameter.
 The Sieve language is described in RFC 3028.  @xref{Top, Emacs Sieve,
 Top, sieve, Emacs Sieve}.
 
+@item match-list
+@cindex match-list
+If this parameter is set to @code{t} and @code{nnmail-split-method} is
+set to @code{gnus-group-split}, Gnus will lookup mail addresses
+against the @code{list} split abbreviation.
+
+See @code{nnmail-split-abbrev-alist} for the regular expression
+matching mailing-list headers.
+
+See @pxref{Group Mail Splitting} to automatically split on group
+parameters.
+
 @item (agent parameters)
 If the agent has been enabled, you can set any of its parameters to
 control the behavior of the agent in individual groups.  See Agent
@@ -15403,6 +15415,9 @@ Matches the @samp{To}, @samp{Cc}, @samp{Apparently-To},
 @samp{Resent-To} and @samp{Resent-Cc} fields.
 @item any
 Is the union of the @code{from} and @code{to} entries.
+@item list
+Matches the @samp{List-Post}, @samp{X-BeenThere} and @samp{X-Loop}
+fields.
 @end table
 
 @vindex nnmail-split-fancy-syntax-table


Footnotes: 
[1]  http://git.baby-gnu.net/gitweb/gitweb.cgi?p=gnus.git;a=tag;h=refs/tags/feature/group-mail-splitting-on-list-headers

-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x7A6FE2DF

[-- Attachment #2: Type: application/pgp-signature, Size: 229 bytes --]

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

* Re: [PATCH] Re: Group splitting on list headers
  2013-12-27 15:57       ` [PATCH] " Daniel Dehennin
@ 2013-12-28  1:53         ` Daniel Dehennin
  2013-12-29  0:25         ` Daniel Dehennin
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel Dehennin @ 2013-12-28  1:53 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 667 bytes --]

Hello,

Looking at group mail splitting I found several room of improvement:

- make sure to use an email only once, when “to-address” and “to-list”
  are equal the same mail is present two times in “nnmail-split-fancy”

- use “regexp-opt” for to-address, to-list and extra-aliases

- as ding mailing list does not define “List-Post” headers, we shoud take
  the “to-address” and “to-list” mails, replace the “@” with “.” and add
  “List-ID” to “nnmail-split-abbrev-alist”

Any comment welcome.

Regards.

-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x7A6FE2DF

[-- Attachment #2: Type: application/pgp-signature, Size: 229 bytes --]

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

* Re: [PATCH] Re: Group splitting on list headers
  2013-12-27 15:57       ` [PATCH] " Daniel Dehennin
  2013-12-28  1:53         ` Daniel Dehennin
@ 2013-12-29  0:25         ` Daniel Dehennin
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel Dehennin @ 2013-12-29  0:25 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 1357 bytes --]

Daniel Dehennin <daniel.dehennin@baby-gnu.org> writes:

> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
>> Uhm...  perhaps `match-list'?
>
> Shortest is best ;-)
>
> You can review my proposal patch on my gitweb[1] or with the following
> pull request.

Matching “extra-aliases” against list headers is not very useful in my
use-case as I set it “admin-address” to group management mails in the same
group as the mailing-list.

It looks to be more useful by generating a split like the following:

#+begin_src emacs-lisp
(| (list (regexp-opt (list to-address to-list)) group)
   (any (regexp-opt (if (listp extra-aliases)
			extra-aliases
		      (list extra-aliases))) group))
#+end_src

I think we could use the “match-list” with several values:

- nil: match “to-address”, “to-list” and “extra-aliases” against 'any
  abbreviation
  
- t: match “to-address” and “to-list” against 'list abbreviation and
  “extra-aliases” against 'any

- 'with-extra-aliases: match “to-address”, “to-list” and “extra-aliases”
  against 'list abbreviation

To reduce complexity in “gnus-group-split-fancy” a new helper to build
the SPLIT should be added.

Any comment?

Regards.

-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x7A6FE2DF

[-- Attachment #2: Type: application/pgp-signature, Size: 229 bytes --]

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

end of thread, other threads:[~2013-12-29  0:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-14 17:03 Group splitting on list headers Daniel Dehennin
2013-12-26 15:47 ` Lars Ingebrigtsen
2013-12-26 16:58   ` Daniel Dehennin
2013-12-26 16:59     ` Lars Ingebrigtsen
2013-12-27 15:57       ` [PATCH] " Daniel Dehennin
2013-12-28  1:53         ` Daniel Dehennin
2013-12-29  0:25         ` Daniel Dehennin

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 NNTP newsgroup(s).