all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#25346: [PATCH] Gnus Group Mail Spliting on mailing-list headers
@ 2017-01-03 17:59 Daniel Dehennin
  2018-04-11 22:40 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Dehennin @ 2017-01-03 17:59 UTC (permalink / raw)
  To: 25346


[-- Attachment #1.1: Type: text/plain, Size: 689 bytes --]

Package: emacs
Severity: wishlist
Tags: patch

Hello,

This patch implement Group Mail Spliting on mailing-list headers, I'm
using it since a long time now.

This avoid the burden of cross-mailing-list posting when a mail is
sent to 4 mailing-lists and finish duplicated 4 times in each
mailing-list group.

The trick is to to mangle the split-regexp to conform with RFC2919 list
IDs.

The following `gnus-parameters`:

#+begin_src emacs-lisp
    ("gnu.emacs.gnus.ding"
     (to-list . "ding@gnus.org")
     (match-list . t)
     (subscribed . t))
#+end_src

Produce the following fancy split:

#+begin_src emacs-lisp
    (list "\\(ding[@.]gnus\\.org\\)" "gnu.emacs.gnus.ding")
#+end_src


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: Gnus Add Group Mail Spliting on mailing-list headers --]
[-- Type: text/x-diff, Size: 5081 bytes --]

From 20bc756adcb8864fa5ec43d22b19db3ec2efaafc Mon Sep 17 00:00:00 2001
From: Daniel Dehennin <daniel.dehennin@baby-gnu.org>
Date: Tue, 3 Jan 2017 18:44:18 +0100
Subject: [PATCH] Gnus Group Mail Spliting on mailing-list headers

This avoid the burden of cross-mailing-list posting when a mail is
sent to 4 mailing-lists and finish duplicated 4 times in each
mailing-list group.

* lisp/nnmail.el: Add new `list' split abbreviation matching common
  mailing-list headers.

* lisp/gnus-mlspl.el: Use the `list' abbreviation when the new
  `match-list' group parameter is set to `t'.
  The split regexp is modified to match either `@` or `.` as domain
  separator to comply with RFC2919 IDs too.

* texi/gnus.texi: Document the new `list' split abbreviation and
  `match-list' group parameter.
---
 doc/misc/gnus.texi      | 18 ++++++++++++++++++
 lisp/gnus/gnus-mlspl.el | 25 +++++++++++++++++++------
 lisp/gnus/nnmail.el     |  3 ++-
 3 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index 05159d4b2f..dba51f1dda 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -3108,6 +3108,21 @@ 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 match @code{to-address},
+@code{to-list}, @code{extra-aliases} and @code{split-regexp} against
+the @code{list} split abbreviation.  The split regexp is modified to
+match either a @code{@@} or a dot @code{.} in mail addresses to
+conform to RFC2919 @code{List-ID}.
+
+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
@@ -15469,6 +15484,9 @@ Matches the @samp{To}, @samp{Cc}, @samp{Apparently-To},
 @item any
 Is the union of the @code{from} and @code{to} entries.
 @end table
+@item list
+Matches the @samp{List-ID}, @samp{List-Post}, @samp{X-Mailing-List},
+@samp{X-BeenThere} and @samp{X-Loop} fields.
 
 @vindex nnmail-split-fancy-syntax-table
 @code{nnmail-split-fancy-syntax-table} is the syntax table in effect
diff --git a/lisp/gnus/gnus-mlspl.el b/lisp/gnus/gnus-mlspl.el
index c42c34adce..378a06100e 100644
--- a/lisp/gnus/gnus-mlspl.el
+++ b/lisp/gnus/gnus-mlspl.el
@@ -184,7 +184,8 @@ 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-list (cdr (assoc 'match-list params))))
 		(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
@@ -204,16 +205,28 @@ Calling (gnus-group-split-fancy nil nil \"mail.others\") returns:
 			  "\\|")
 			 "\\)"))
 		  ;; Now create the new SPLIT
-		  (push (append
-			 (list 'any split-regexp)
+		  (let ((split-regexp-with-list-ids
+			 (replace-regexp-in-string "@" "[@.]" split-regexp t t))
+			(exclude
 			 ;; Generate RESTRICTs for SPLIT-EXCLUDEs.
 			 (if (listp split-exclude)
 			     (apply #'append
 				    (mapcar (lambda (arg) (list '- arg))
 					    split-exclude))
-			   (list '- split-exclude))
-			 (list group-clean))
-			split)
+			   (list '- split-exclude))))
+
+		    (if match-list
+			;; Match RFC2919 IDs or mail addresses
+			(push (append
+			       (list 'list split-regexp-with-list-ids)
+			       exclude
+			       (list group-clean))
+			      split)
+		      (push (append
+			     (list 'any split-regexp)
+			     exclude
+			     (list group-clean))
+			    split)))
 		  ;; If it matches the empty string, it is a catch-all
 		  (when (string-match split-regexp "")
 		    (setq catch-all nil)))))))))
diff --git a/lisp/gnus/nnmail.el b/lisp/gnus/nnmail.el
index 3f2e08171e..96be94922c 100644
--- a/lisp/gnus/nnmail.el
+++ b/lisp/gnus/nnmail.el
@@ -488,7 +488,8 @@ Example:
     (to . "to\\|cc\\|apparently-to\\|resent-to\\|resent-cc")
     (from . "from\\|sender\\|resent-from")
     (nato . "to\\|cc\\|resent-to\\|resent-cc")
-    (naany . "from\\|to\\|cc\\|sender\\|resent-from\\|resent-to\\|resent-cc"))
+    (naany . "from\\|to\\|cc\\|sender\\|resent-from\\|resent-to\\|resent-cc")
+    (list . "list-id\\|list-post\\|x-mailing-list\||x-beenthere\\|x-loop"))
   "Alist of abbreviations allowed in `nnmail-split-fancy'."
   :group 'nnmail-split
   :type '(repeat (cons :format "%v" symbol regexp)))
-- 
2.11.0


[-- Attachment #1.3: Type: text/plain, Size: 162 bytes --]


Regards.
-- 
Daniel Dehennin
Récupérer ma clef GPG: gpg --recv-keys 0xCC1E9E5B7A6FE2DF
Fingerprint: 3E69 014E 5C23 50E8 9ED6  2AAD CC1E 9E5B 7A6F E2DF


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 357 bytes --]

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

* bug#25346: [PATCH] Gnus Group Mail Spliting on mailing-list headers
  2017-01-03 17:59 bug#25346: [PATCH] Gnus Group Mail Spliting on mailing-list headers Daniel Dehennin
@ 2018-04-11 22:40 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2018-04-11 22:40 UTC (permalink / raw)
  To: Daniel Dehennin; +Cc: 25346

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

> This patch implement Group Mail Spliting on mailing-list headers, I'm
> using it since a long time now.
>
> This avoid the burden of cross-mailing-list posting when a mail is
> sent to 4 mailing-lists and finish duplicated 4 times in each
> mailing-list group.
>
> The trick is to to mangle the split-regexp to conform with RFC2919 list
> IDs.

Looks good; I've applied it to Emacs 27.1.

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





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

end of thread, other threads:[~2018-04-11 22:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-03 17:59 bug#25346: [PATCH] Gnus Group Mail Spliting on mailing-list headers Daniel Dehennin
2018-04-11 22:40 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.