Gnus development mailing list
 help / color / mirror / Atom feed
* [PROPOSAL] nnfolder-generate-active-file extension
@ 2004-01-19 21:54 Adrian Lanz
  2004-05-16 19:05 ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Adrian Lanz @ 2004-01-19 21:54 UTC (permalink / raw)


BACKGROUND
This is a proposal for solving a problem that has been addressed a
couple times from different people, which create (typically through
mail splitting rules) many nnfolder groups.

MOTIVATION
I personally create a nnfolder group for every reasonable (hopefully
not spam) net address I get mail messages from. The result is, that I
get an immediate overview over all new and "somehow important" (that
is ticked) messages by person in the group buffer, and - as I split
also outgoing messages by the net address of the receiver - I find the
entire correspondence with that and only that person in a single
group. Well this whole thing is probabely a matter of taste. I am just
used to it for a long time now. 10 years ago, I actually thought of
keeping at least the most important correspondence in archives
collected this way, but this turned out to make little sense in the
long run. At the moment, the archives are sorted by year and - for
"historcal reasons" still by some important domain names of the
senders or receivers net address. But searching is done over all
archives through nnir with swish-e.

PROBLEM
The problem with such a setup is, that after a couple of weeks or
years (in my case) and with mail expiry constantly doing its fine job
in the background, most nnfolder groups are actualy empty. I could go
through all groups to find out the empty ones and kill them "by hand"
(gnus-group-delete-group), but this is not only boring, but also
error-prone.

SOLUTION
The below patch implements a means to delete empty nnfolder groups in
the process of generating a new active file for the nnfolder backend
(by giving a prefix to function nnfolder-generate-active-file).

REQUEST FOR COMMENTS
The patch works for me as intended, but before asking to implemente
the additional functionality in Gnus, it would be reasonable to
discuss the utility and potential hazards and caveats on the
list. Please do!

Thanks, Adrian.



diff -c tmp/old.el tmp/new.el
*** tmp/old.el	2004-01-19 19:42:36.613419000 +0100
--- tmp/new.el	2004-01-19 21:28:55.763432000 +0100
***************
*** 1,6 ****
! (defun nnfolder-generate-active-file ()
!   "Look for mbox folders in the nnfolder directory and make them into groups.
! This command does not work if you use short group names."
    (interactive)
    (nnmail-activate 'nnfolder)
    (unless (or gnus-nov-is-evil nnfolder-nov-is-evil)
--- 1,11 ----
! (defun nnfolder-generate-active-file (&optional force)
!   "Look for mbox folders in the nnfolder directory and make them
! into groups. If FORCE (the prefix) is non-nil, delete all groups
! in the nnfolder back end for which a corresponding file is found
! in the the nnfolder directory that does not folow the mbox
! format (typically an empty file corresponding to an empty group
! in the nnfolder back end). There is no undo. This command does
! not work if you use short group names."
    (interactive)
    (nnmail-activate 'nnfolder)
    (unless (or gnus-nov-is-evil nnfolder-nov-is-evil)
***************
*** 16,33 ****
    (let ((files (directory-files nnfolder-directory))
  	file)
      (while (setq file (pop files))
!       (when (and (not (backup-file-name-p file))
! 		 (message-mail-file-mbox-p
! 		  (nnheader-concat nnfolder-directory file)))
! 	(let ((oldgroup (assoc file nnfolder-group-alist)))
! 	  (if oldgroup
! 	      (nnheader-message 5 "Refreshing group %s..." file)
! 	    (nnheader-message 5 "Adding group %s..." file))
! 	  (if oldgroup
! 	      (setq nnfolder-group-alist
! 		    (delq oldgroup (copy-sequence nnfolder-group-alist))))
! 	  (push (list file (cons 1 0)) nnfolder-group-alist)
! 	  (nnfolder-possibly-change-folder file)
! 	  (nnfolder-possibly-change-group file)
! 	  (nnfolder-close-group file))))
      (nnheader-message 5 "")))
--- 21,45 ----
    (let ((files (directory-files nnfolder-directory))
  	file)
      (while (setq file (pop files))
!       (when (not (backup-file-name-p file))
! 	(if (message-mail-file-mbox-p (nnheader-concat nnfolder-directory file))
! 	    (let ((oldgroup (assoc file nnfolder-group-alist)))
! 	      (if oldgroup
! 		  (nnheader-message 5 "Refreshing group %s..." file)
! 		(nnheader-message 5 "Adding group %s..." file))
! 	      (if oldgroup
! 		  (setq nnfolder-group-alist
! 			(delq oldgroup (copy-sequence nnfolder-group-alist))))
! 	      (push (list file (cons 1 0)) nnfolder-group-alist)
! 	      (nnfolder-possibly-change-folder file)
! 	      (nnfolder-possibly-change-group file)
! 	      (nnfolder-close-group file))
! 	  (let ((oldgroup (assoc file nnfolder-group-alist)))
! 	    (when (and force oldgroup)
! 	      (nnheader-message 5 "Removing group %s..." file)
! 	      (nnfolder-possibly-change-folder file)
! 	      (nnfolder-possibly-change-group file)
! 	      (if (eq 0 (nth 7 (file-attributes (nnheader-concat nnfolder-directory file))))
! 		  (nnfolder-request-delete-group file t)
! 		(nnfolder-request-delete-group file)))))))
      (nnheader-message 5 "")))

Diff finished at Mon Jan 19 21:30:57



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

* Re: [PROPOSAL] nnfolder-generate-active-file extension
  2004-01-19 21:54 [PROPOSAL] nnfolder-generate-active-file extension Adrian Lanz
@ 2004-05-16 19:05 ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Magne Ingebrigtsen @ 2004-05-16 19:05 UTC (permalink / raw)


Adrian Lanz <lanz@fowi.ethz.ch> writes:

> The below patch implements a means to delete empty nnfolder groups in
> the process of generating a new active file for the nnfolder backend
> (by giving a prefix to function nnfolder-generate-active-file).

I think this sounds like a very good idea.

-- 
(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:[~2004-05-16 19:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-19 21:54 [PROPOSAL] nnfolder-generate-active-file extension Adrian Lanz
2004-05-16 19:05 ` 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).