Gnus development mailing list
 help / color / mirror / Atom feed
From: Reiner Steib <reinersteib+gmane@imap.cc>
To: Sven Joachim <svenjoac@gmx.de>, ding@gnus.org
Cc: gmane-discuss@hawk.netfonds.no
Subject: Fixing Gmane's mangled MIDs (was: Stop messing with Message-IDs, you're ruining threading)
Date: Mon, 08 Dec 2008 20:17:46 +0100	[thread overview]
Message-ID: <87fxkyxyqt.fsf@marauder.physik.uni-ulm.de> (raw)
In-Reply-To: <87myf8gsdj.fsf@turtle.gmx.de>

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

On Sun, Dec 07 2008, Sven Joachim wrote:

> On 2008-12-07 06:50 +0100, Lars Magne Ingebrigtsen wrote:
>> When the same message comes from two mailing lists, and there's not
>> enough information in them to identify them as such (to crosspost the
>> message between the list), the Message-ID has to be renamed.  Remove the
>> bit after __ to find the original ID.
>
> Here is some Emacs lisp code that does this automatically when replying
> in Gnus:
>
> (defun sj-unmangle-gmane-message-id ()
>   "Undo the Message-ID mangling that Gmane does on some postings."
>   (save-excursion
>     (save-restriction
>       (message-narrow-to-headers)
>       (goto-char (point-min))
>       (while
> 	  (re-search-forward "\\(<.*\\)" (point-max) t)
> 	(replace-match "\\1")))))

I would have expected a search for an expression like
"__[0-9.]+\\$gmane\\$org@" or similar.  What am I missing?

> ;; Fix up References header
> (add-hook 'message-header-setup-hook
> 	  'sj-unmangle-gmane-message-id)
>
> ;; Fix up In-Reply-To header
> (add-hook 'message-send-mail-hook
> 	  'sj-unmangle-gmane-message-id)
>
> Note that your own Gcc'ed copy will still have the mangled Message-ID in
> the In-Reply-To header, because message.el inserts that very late.  I
> can live with that, but if somebody has a better idea, please let me
> know.

I'd guess the unmangling should be done when `message-id' (fixing
References should not be necessary, I think) is put into
`message-reply-headers' (in `message-cite-original-1',
`message-reply', `message-followup'?).

Here's a very rough, untested patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: rs-message-unmangle-Gmane.patch --]
[-- Type: text/x-patch, Size: 2632 bytes --]

Index: message.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/message.el,v
retrieving revision 7.277
diff -u -u -r7.277 message.el
--- message.el	6 Dec 2008 17:30:03 -0000	7.277
+++ message.el	8 Dec 2008 19:12:15 -0000
@@ -3665,6 +3667,23 @@
 	  (push (buffer-name buffer) buffers))))
     (nreverse buffers)))
 
+(defcustom message-gmane-mangled-mid-regexp
+  ;; FIXME: Don't use gnus-...
+  (concat "\\(<" gnus-button-valid-localpart-regexp "\\)"
+	  "__[0-9a-z.$]+\\$gmane\\$org" ;; bogus part
+	  ;; message-valid-fqdn-regexp probably would be too strict here
+	  "\\(@[a-z0-9][-.a-z0-9]+>\\)")
+  "FIXME"
+  :version "23.1" ;; No Gnus
+  :group 'message-headers
+  :type '(choice (const :tag "Don't unmangle MIDs" nil)
+		 regexp))
+
+(defun message-fix-gmane-mids (mids)
+  ;; FIXME: Don't use gnus-...
+  (gnus-replace-in-string mids message-gmane-mangled-mid-regexp
+			  "\\1\\2"))
+
 (defun message-cite-original-1 (strip-signature)
   "Cite an original message.
 If STRIP-SIGNATURE is non-nil, strips off the signature from the
@@ -3694,7 +3713,11 @@
 		      (or (message-fetch-field "subject") "none")
 		      (or (message-fetch-field "from") "nobody")
 		      (message-fetch-field "date")
-		      (message-fetch-field "message-id" t)
+		      (funcall
+		       (if (stringp message-gmane-mangled-mid-regexp)
+			   'message-fix-gmane-mids
+			 'identity)
+		       (message-fetch-field "message-id" t))
 		      (message-fetch-field "references")
 		      0 0 ""))))
       (mml-quote-region start end)
@@ -6622,7 +6658,11 @@
 	  (save-excursion
 	    (setq follow-to
 		  (funcall message-wide-reply-to-function)))))
-      (setq message-id (message-fetch-field "message-id" t)
+      (setq message-id (funcall
+			(if (stringp message-gmane-mangled-mid-regexp)
+			    'message-fix-gmane-mids
+			  'identity)
+			(message-fetch-field "message-id" t))
 	    references (message-fetch-field "references")
 	    date (message-fetch-field "date")
 	    from (or (message-fetch-field "from") "nobody")
@@ -6683,7 +6723,11 @@
 	    date (message-fetch-field "date")
 	    subject (or (message-fetch-field "subject") "none")
 	    references (message-fetch-field "references")
-	    message-id (message-fetch-field "message-id" t)
+	    message-id (funcall
+			(if (stringp message-gmane-mangled-mid-regexp)
+			    'message-fix-gmane-mids
+			  'identity)
+			(message-fetch-field "message-id" t))
 	    followup-to (message-fetch-field "followup-to")
 	    newsgroups (message-fetch-field "newsgroups")
 	    posted-to (message-fetch-field "posted-to")

[-- Attachment #3: Type: text/plain, Size: 199 bytes --]


Bye, Reiner.

[ Omitted gmane.dicuss from Mail-Followup-To as this is only relevant
  for Gnus. ]
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

[-- Attachment #4: Type: text/plain, Size: 169 bytes --]

_______________________________________________
Gmane-discuss mailing list
Gmane-discuss@hawk.netfonds.no
http://hawk.netfonds.no/cgi-bin/mailman/listinfo/gmane-discuss

       reply	other threads:[~2008-12-08 19:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87d4go7hmd.fsf@jidanni.org>
     [not found] ` <m3fxl0wn33.fsf@quimbies.gnus.org>
     [not found]   ` <87myf8gsdj.fsf@turtle.gmx.de>
2008-12-08 19:17     ` Reiner Steib [this message]
2008-12-08 20:59       ` Fixing Gmane's mangled MIDs Sven Joachim

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

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

  git send-email \
    --in-reply-to=87fxkyxyqt.fsf@marauder.physik.uni-ulm.de \
    --to=reinersteib+gmane@imap.cc \
    --cc=Reiner.Steib@gmx.de \
    --cc=ding@gnus.org \
    --cc=gmane-discuss@hawk.netfonds.no \
    --cc=svenjoac@gmx.de \
    /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.
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).