Gnus development mailing list
 help / color / mirror / Atom feed
* Automatic archiving of old mail, questions about gnus internals
@ 1999-06-14 22:06 Matt Pharr
  1999-07-03  9:13 ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Pharr @ 1999-06-14 22:06 UTC (permalink / 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>


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

* Re: Automatic archiving of old mail, questions about gnus internals
  1999-06-14 22:06 Automatic archiving of old mail, questions about gnus internals Matt Pharr
@ 1999-07-03  9:13 ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Magne Ingebrigtsen @ 1999-07-03  9:13 UTC (permalink / raw)


Matt Pharr <mmp@Graphics.Stanford.EDU> writes:

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

Yeah, or

(setq groups (mapcar (lambda (g) (gnus-info-group g)) (cdr gnus-newsrc-alist)))

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

Misunderstanding.  That function prompts on `gnus-large-newsgroup';
the parameters only say what subsection of the articles to consider
before prompting.

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

(if (zerop (buffer-size)) ...)

:-)

I actually think that's how Gnus checks when it needs to check, which
isn't often.

> Is there a better way to do this sort of thing in general (for each group,
> for these articles, move them here)?

Well, I think there should be a general "iterate over these groups,
enter them, and do *this*" function in Gnus.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen


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

end of thread, other threads:[~1999-07-03  9:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-14 22:06 Automatic archiving of old mail, questions about gnus internals Matt Pharr
1999-07-03  9:13 ` Lars Magne Ingebrigtsen

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