Gnus development mailing list
 help / color / mirror / Atom feed
From: Matt Pharr <mmp@Graphics.Stanford.EDU>
Subject: Automatic archiving of old mail, questions about gnus internals
Date: 14 Jun 1999 15:06:25 -0700	[thread overview]
Message-ID: <kh0yahmxwri.fsf@lux.Stanford.EDU> (raw)


I've written a little function that goes through nnml groups and moves old
mails to nnfolder groups (i.e. stuff older than n days in nnml:mail.foo is
moved to nnfolder:archive.mail.foo).  (Code is below.)  I'm not sure how
correctly I did various things in the code--thus some questions about gnus
internals:

1. What is the preferred way to get a list of all of the subscribed
newsgroups?  I've copied some code from somewhere that does:

  (let ((newsrc (cdr gnus-newsrc-alist))
	group)
    (while newsrc
      (setq group (gnus-info-group (car newsrc)))
      ;; do stuff with group
      (setq newsrc (cdr newsrc))))

Is that the best way to do it?  I couldn't find predefined functionality
that does this.

2. My reading of the doc string for gnus-group-read-group suggests that
(gnus-group-read-group t t group) should generate a summary buffer for
group with all of the articles in it.  In particular, I expect it to not
pay attention to the value of gnus-large-newsgroup.  However, it does seem
to be looking at gnus-large-newsgroup and asking me how many articles I
want to fetch, when I just wish it would go ahead.  Bug or
misunderstanding?

3. After doing various limiting in the summary buffer, I'd like to see if
there are any articles remaining.  Somehow doing
  (if (> (- (point-max) (point-min)) 0)
seems like a big hack.  Is there a better way to check?

Is there a better way to do this sort of thing in general (for each group,
for these articles, move them here)?  Any other comments about the code?
Given fixes/suggestions that make this less ugly, I'll submit it as an
addition to gnus-demon.el.

thanks,
-matt

(defun mmp:archive-old-mail ()
  (interactive)
  (let ((newsrc (cdr gnus-newsrc-alist))
	group archive-group)
    (while newsrc
      (setq group (gnus-info-group (car newsrc)))
      (if (and (string-match "^nnml:mail." group)
	       (gnus-group-read-group 9999999 t group))
	  (gnus-atomic-progn
	    (setq archive-group 
		  (concat "nnfolder:archive."
			  (replace-match "" nil t group)))
	    (gnus-summary-limit-to-age 180)
	    (gnus-summary-limit-to-marks "!" t)
	    (gnus-uu-mark-buffer)
	    (if (> (- (point-max) (point-min)) 0)
		(progn
		  (gnus-message 5 "Archiving old messages from %s to %s..." 
				group archive-group)
		  (gnus-summary-move-article nil archive-group)
		  (gnus-summary-exit)))))
      (setq newsrc (cdr newsrc)))))

-- 
Matt Pharr                                   mmp@graphics.stanford.edu
<URL:http://graphics.stanford.edu/~mmp>


             reply	other threads:[~1999-06-14 22:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-14 22:06 Matt Pharr [this message]
1999-07-03  9:13 ` Lars Magne Ingebrigtsen

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=kh0yahmxwri.fsf@lux.Stanford.EDU \
    --to=mmp@graphics.stanford.edu \
    /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).