From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: ding@gnus.org
Subject: code query
Date: Fri, 14 Dec 2012 13:53:47 +0800 [thread overview]
Message-ID: <87bodx5gd0.fsf@ericabrahamsen.net> (raw)
I've been trying for a while to write a function for marking all
duplicate messages in an nnmail group. So far I've got the below, which
works okay up to a point. It gets all the messages in a group, then
takes gnus-newsgroup-data, sorts it according to Message-ID, and sets
the process mark on any message that has the same Message-ID as the one
before. I was going to have it add Gnus-Warning headers, but have so far
failed to edit the messages programmatically.
The problem with the below is that it seems to create one "pseudo article"
for each block of consecutive identical messages -- the pseudo article
is a new copy of that message, but can't be opened or displayed
properly, nor deleted. They're also persistent, so the more I run my
function the more "duplicate" messages I get!
From what I can tell, pseudo articles are created in the course of
decoding raw messages. I assume I need to do some cleanup on the article
or on the summary buffer, either before `gnus-summary-set-process-mark'
is called, or afterwards (or both). Or perhaps after the whole process
is done?
Can anyone shed any light on this?
Thanks!
Eric
--8<---------------cut here---------------start------------->8---
(defun my-gnus-warn-duplicates (group)
"Go through a group and mark all messages that are duplicates
of other messages, according to the value of Message-ID."
(interactive (list (gnus-group-group-name)))
(let ((gnus-large-newsgroup nil)
(gnus-registry-enabled nil)) ;doesn't work
(gnus-message 5 "Marking duplicate messages, this may take a while...")
(gnus-summary-read-group group t t nil)
(my-gnus-mark-duplicates gnus-newsgroup-data)
(gnus-message 5 "Marked %d duplicate messages")))
(defun my-gnus-mark-duplicates (data)
(let ((data (sort data (lambda (one two)
(string< (mail-header-id (gnus-data-header one))
(mail-header-id (gnus-data-header two))))))
last-id)
(mapcar (lambda (d)
(let ((id (mail-header-id (gnus-data-header d))))
(if (string= id last-id)
(gnus-summary-set-process-mark (gnus-data-number d))
;; there may be spurious marks
(gnus-summary-remove-process-mark (gnus-data-number d)))
(setq last-id id)))
data)))
--8<---------------cut here---------------end--------------->8---
next reply other threads:[~2012-12-14 5:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-14 5:53 Eric Abrahamsen [this message]
2012-12-14 13:43 ` Andreas Schwab
2012-12-15 0:18 ` Eric Abrahamsen
2012-12-25 11:48 ` Lars Ingebrigtsen
2012-12-26 2:59 ` Eric Abrahamsen
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=87bodx5gd0.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=ding@gnus.org \
/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).