Gnus development mailing list
 help / color / mirror / Atom feed
* code query
@ 2012-12-14  5:53 Eric Abrahamsen
  2012-12-14 13:43 ` Andreas Schwab
  2012-12-25 11:48 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Abrahamsen @ 2012-12-14  5:53 UTC (permalink / raw)
  To: ding

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---




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

end of thread, other threads:[~2012-12-26  2:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-14  5:53 code query Eric Abrahamsen
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

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).